Merge branch 'thriqon-bug-author-committer'
This commit is contained in:
commit
ac576077ab
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
||||||
`import TravisRoute from 'travis/routes/basic'`
|
`import TravisRoute from 'travis/routes/basic'`
|
||||||
`import config from 'travis/config/environment'`
|
`import config from 'travis/config/environment'`
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
||||||
`import { durationFrom, safe } from 'travis/utils/helpers'`
|
`import { durationFrom, safe } from 'travis/utils/helpers'`
|
||||||
`import { githubCommit } from 'travis/utils/urls'`
|
`import { githubCommit } from 'travis/utils/urls'`
|
||||||
|
@ -10,22 +9,6 @@ BuildHeaderComponent = Ember.Component.extend
|
||||||
classNames: ['build-header']
|
classNames: ['build-header']
|
||||||
classNameBindings: ['item.state']
|
classNameBindings: ['item.state']
|
||||||
|
|
||||||
committerAvatarUrl: (->
|
|
||||||
if url = @get('commit.committerAvatarUrl')
|
|
||||||
url
|
|
||||||
else
|
|
||||||
email = @get('commit.committerEmail')
|
|
||||||
gravatarImage(email, 40)
|
|
||||||
).property('commit.committerEmail', 'commit.committerAvatarUrl')
|
|
||||||
|
|
||||||
authorAvatarUrl: (->
|
|
||||||
if url = @get('commit.authorAvatarUrl')
|
|
||||||
url
|
|
||||||
else
|
|
||||||
email = @get('commit.authorEmail')
|
|
||||||
gravatarImage(email, 40)
|
|
||||||
).property('commit.authorEmail', 'commit.authorAvatarUrl')
|
|
||||||
|
|
||||||
isJob: (->
|
isJob: (->
|
||||||
if @get('item.build') then true else false
|
if @get('item.build') then true else false
|
||||||
).property('item')
|
).property('item')
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
|
||||||
|
|
||||||
BuildsItemComponent = Ember.Component.extend
|
BuildsItemComponent = Ember.Component.extend
|
||||||
|
@ -7,14 +6,6 @@ BuildsItemComponent = Ember.Component.extend
|
||||||
classNameBindings: ['build.state']
|
classNameBindings: ['build.state']
|
||||||
classNames: ['row-li', 'pr-row']
|
classNames: ['row-li', 'pr-row']
|
||||||
|
|
||||||
authorAvatarUrl: (->
|
|
||||||
if url = @get('build.commit.authorAvatarUrl')
|
|
||||||
url
|
|
||||||
else
|
|
||||||
email = @get('build.commit.authorEmail')
|
|
||||||
gravatarImage(email, 40)
|
|
||||||
).property('build.commit.authorEmail', 'build.commit.authorAvatarUrl')
|
|
||||||
|
|
||||||
urlGithubCommit: (->
|
urlGithubCommit: (->
|
||||||
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
|
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
|
||||||
).property('build.commit.sha')
|
).property('build.commit.sha')
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
||||||
|
|
||||||
BranchesController = Ember.Controller.extend
|
BranchesController = Ember.Controller.extend
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { gravatarImage } from 'travis/utils/urls'`
|
|
||||||
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
|
||||||
|
|
||||||
Controller = Ember.Controller.extend GithubUrlPropertievs,
|
Controller = Ember.Controller.extend GithubUrlPropertievs,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import Model from 'travis/models/model'`
|
`import Model from 'travis/models/model'`
|
||||||
`import Build from 'travis/models/build'`
|
`import Build from 'travis/models/build'`
|
||||||
|
`import { gravatarImage } from 'travis/utils/urls'`
|
||||||
|
|
||||||
Commit = Model.extend
|
Commit = Model.extend
|
||||||
sha: DS.attr()
|
sha: DS.attr()
|
||||||
|
@ -34,4 +35,20 @@ Commit = Model.extend
|
||||||
@get('authorEmail') == @get('committerEmail')
|
@get('authorEmail') == @get('committerEmail')
|
||||||
).property('authorName', 'authorEmail', 'committerName', 'committerEmail')
|
).property('authorName', 'authorEmail', 'committerName', 'committerEmail')
|
||||||
|
|
||||||
|
authorAvatarUrl: (->
|
||||||
|
if url = @get('authorAvatarUrl')
|
||||||
|
url
|
||||||
|
else
|
||||||
|
email = @get('authorEmail')
|
||||||
|
gravatarImage(email, 40)
|
||||||
|
).property('authorEmail', 'authorAvatarUrl')
|
||||||
|
|
||||||
|
committerAvatarUrl: (->
|
||||||
|
if url = @get('committerAvatarUrl')
|
||||||
|
url
|
||||||
|
else
|
||||||
|
email = @get('committerEmail')
|
||||||
|
gravatarImage(email, 40)
|
||||||
|
).property('committerEmail', 'committerAvatarUrl')
|
||||||
|
|
||||||
`export default Commit`
|
`export default Commit`
|
||||||
|
|
|
@ -38,11 +38,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
<p class="commit-author">
|
<p class="commit-author">
|
||||||
{{#if commit.authorName}}
|
{{#if commit.authorName}}
|
||||||
<img src={{authorAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
|
<img src={{commit.authorAvatarUrl}} alt="author avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#unless commit.authorIsCommitter}}
|
{{#unless commit.authorIsCommitter}}
|
||||||
{{#if commit.committerName}}
|
{{#if commit.committerName}}
|
||||||
<img src={{committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
|
<img src={{commit.committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
<div class="row-item row-committer">
|
<div class="row-item row-committer">
|
||||||
<img class="avatar" src={{authorAvatarUrl}} alt="{{build.commit.committerName}} avatar">
|
<img class="avatar" src={{build.commit.authorAvatarUrl}} alt="{{build.commit.authorName}} avatar">
|
||||||
<span class="label-align">{{build.commit.committerName}}</span>
|
<span class="label-align">{{build.commit.authorName}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
`import Ember from 'ember'`
|
`import Ember from 'ember'`
|
||||||
`import { colorForState } from 'travis/utils/helpers'`
|
`import { colorForState } from 'travis/utils/helpers'`
|
||||||
`import { githubCommit, gravatarImage } from 'travis/utils/urls'`
|
`import { githubCommit } from 'travis/utils/urls'`
|
||||||
`import Polling from 'travis/mixins/polling'`
|
`import Polling from 'travis/mixins/polling'`
|
||||||
|
|
||||||
View = Ember.View.extend Polling,
|
View = Ember.View.extend Polling,
|
||||||
|
@ -20,12 +20,4 @@ View = Ember.View.extend Polling,
|
||||||
githubCommit(@get('repo.slug'), @get('commit.sha'))
|
githubCommit(@get('repo.slug'), @get('commit.sha'))
|
||||||
).property('repo.slug', 'commit.sha')
|
).property('repo.slug', 'commit.sha')
|
||||||
|
|
||||||
urlCommitterGravatarImage: (->
|
|
||||||
gravatarImage(@get('commit.committerEmail'), 40)
|
|
||||||
).property('commit.committerEmail')
|
|
||||||
|
|
||||||
urlAuthorGravatarImage: (->
|
|
||||||
gravatarImage(@get('commit.authorEmail'), 40)
|
|
||||||
).property('commit.authorEmail')
|
|
||||||
|
|
||||||
`export default View`
|
`export default View`
|
||||||
|
|
|
@ -32,5 +32,4 @@ test 'it renders', (assert) ->
|
||||||
|
|
||||||
ok component.$().hasClass('passed'), 'component has right status class'
|
ok component.$().hasClass('passed'), 'component has right status class'
|
||||||
equal component.$('.row-branch a').text().trim(), 'foobarbranch', 'component renders branch if event is push'
|
equal component.$('.row-branch a').text().trim(), 'foobarbranch', 'component renders branch if event is push'
|
||||||
equal component.$('.avatar').attr('src'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=https%3A%2F%2Ftravis-ci.org%2Fimages%2Fui%2Fdefault-avatar.png', 'component renders right gravatar image'
|
|
||||||
equal component.$('a[title="See the commit on GitHub"]').attr('href'), 'https://github.com/foo/bar/commit/a5e8093098f9c0fb46856b753fb8943c7fbf26f3', 'component generates right commit link'
|
equal component.$('a[title="See the commit on GitHub"]').attr('href'), 'https://github.com/foo/bar/commit/a5e8093098f9c0fb46856b753fb8943c7fbf26f3', 'component generates right commit link'
|
||||||
|
|
25
tests/unit/models/commit-test.coffee
Normal file
25
tests/unit/models/commit-test.coffee
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
`import { moduleForModel, test } from 'ember-qunit'`
|
||||||
|
|
||||||
|
moduleForModel 'commit', 'Unit | Model | commit', needs: ['model:build']
|
||||||
|
|
||||||
|
test 'calculation of avatar urls via Gravatar', ->
|
||||||
|
model = @subject()
|
||||||
|
Ember.run ->
|
||||||
|
model.setProperties
|
||||||
|
authorEmail: 'author@example.com'
|
||||||
|
committerEmail: 'author@example.com'
|
||||||
|
authorAvatarUrl: null
|
||||||
|
committerAvatarUrl: null
|
||||||
|
equal model.get('authorAvatarUrlOrGravatar'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=https%3A%2F%2Ftravis-ci.org%2Fimages%2Fui%2Fdefault-avatar.png', 'correctly sets gravatar image'
|
||||||
|
equal model.get('committerAvatarUrlOrGravatar'), 'https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=40&d=https%3A%2F%2Ftravis-ci.org%2Fimages%2Fui%2Fdefault-avatar.png', 'correctly sets gravatar image'
|
||||||
|
|
||||||
|
test 'calculation of avatar urls via overriding parameter', ->
|
||||||
|
model = @subject()
|
||||||
|
Ember.run ->
|
||||||
|
model.setProperties
|
||||||
|
authorEmail: 'author@example.com'
|
||||||
|
committerEmail: 'author@example.com'
|
||||||
|
authorAvatarUrl: 'http://example.com/test.jpg'
|
||||||
|
committerAvatarUrl: 'http://example.com/test2.jpg'
|
||||||
|
equal model.get('authorAvatarUrlOrGravatar'), 'http://example.com/test.jpg', 'correctly sets avatar'
|
||||||
|
equal model.get('committerAvatarUrlOrGravatar'), 'http://example.com/test2.jpg', 'correctly sets avatar'
|
Loading…
Reference in New Issue
Block a user