Revert "Merge branch 'thriqon-bug-author-committer'"

This reverts commit ac576077ab, reversing
changes made to f9263fc8f3.
This commit is contained in:
Piotr Sarnacki 2016-01-04 12:14:44 +01:00
parent e5763ee2d6
commit 4e720519fe
11 changed files with 43 additions and 47 deletions

View File

@ -1,4 +1,5 @@
`import Ember from 'ember'`
`import { gravatarImage } from 'travis/utils/urls'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
`import TravisRoute from 'travis/routes/basic'`
`import config from 'travis/config/environment'`

View File

@ -1,4 +1,5 @@
`import Ember from 'ember'`
`import { gravatarImage } from 'travis/utils/urls'`
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
`import { durationFrom, safe } from 'travis/utils/helpers'`
`import { githubCommit } from 'travis/utils/urls'`
@ -9,6 +10,22 @@ BuildHeaderComponent = Ember.Component.extend
classNames: ['build-header']
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: (->
if @get('item.build') then true else false
).property('item')

View File

@ -1,4 +1,5 @@
`import Ember from 'ember'`
`import { gravatarImage } from 'travis/utils/urls'`
`import { githubCommit as githubCommitUrl } from 'travis/utils/urls'`
BuildsItemComponent = Ember.Component.extend
@ -6,6 +7,14 @@ BuildsItemComponent = Ember.Component.extend
classNameBindings: ['build.state']
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: (->
githubCommitUrl(@get('build.repo.slug'), @get('build.commit.sha'))
).property('build.commit.sha')

View File

@ -1,4 +1,5 @@
`import Ember from 'ember'`
`import { gravatarImage } from 'travis/utils/urls'`
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
BranchesController = Ember.Controller.extend

View File

@ -1,4 +1,5 @@
`import Ember from 'ember'`
`import { gravatarImage } from 'travis/utils/urls'`
`import GithubUrlPropertievs from 'travis/mixins/github-url-properties'`
Controller = Ember.Controller.extend GithubUrlPropertievs,

View File

@ -1,7 +1,6 @@
`import Ember from 'ember'`
`import Model from 'travis/models/model'`
`import Build from 'travis/models/build'`
`import { gravatarImage } from 'travis/utils/urls'`
Commit = Model.extend
sha: DS.attr()
@ -35,20 +34,4 @@ Commit = Model.extend
@get('authorEmail') == @get('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`

View File

@ -38,11 +38,11 @@
</ul>
<p class="commit-author">
{{#if commit.authorName}}
<img src={{commit.authorAvatarUrl}} alt="author avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
<img src={{authorAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.authorName}} authored{{#if commit.authorIsCommitter}} and committed{{/if}}</span>
{{/if}}
{{#unless commit.authorIsCommitter}}
{{#if commit.committerName}}
<img src={{commit.committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
<img src={{committerAvatarUrl}} alt="comitter avatar" aria-hidden="true"><span class="label-align">{{commit.committerName}} committed</span>
{{/if}}
{{/unless}}
</p>

View File

@ -20,8 +20,8 @@
{{/unless}}
</div>
<div class="row-item row-committer">
<img class="avatar" src={{build.commit.authorAvatarUrl}} alt="{{build.commit.authorName}} avatar">
<span class="label-align">{{build.commit.authorName}}</span>
<img class="avatar" src={{authorAvatarUrl}} alt="{{build.commit.committerName}} avatar">
<span class="label-align">{{build.commit.committerName}}</span>
</div>
</div>

View File

@ -1,6 +1,6 @@
`import Ember from 'ember'`
`import { colorForState } from 'travis/utils/helpers'`
`import { githubCommit } from 'travis/utils/urls'`
`import { githubCommit, gravatarImage } from 'travis/utils/urls'`
`import Polling from 'travis/mixins/polling'`
View = Ember.View.extend Polling,
@ -20,4 +20,12 @@ View = Ember.View.extend Polling,
githubCommit(@get('repo.slug'), @get('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`

View File

@ -32,4 +32,5 @@ test 'it renders', (assert) ->
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.$('.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'

View File

@ -1,25 +0,0 @@
`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'