Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-03-24 12:47:22 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2017-03-24 12:47:22 +0300
commitb1699ff7a49f4501e98fe85752a76a0a4745d116 (patch)
treec2a425ad47773dfee7d5431402353ce8e47fc480
parent9bd611faa7747abbc0ce255e2f10a366081c0179 (diff)
parent0759db802f053e2757d52a284fd29098a9473df2 (diff)
Merge branch 'tc-pipeline-show-trigger-date' into 'master'
Correctly show pipeline creator & created_at Closes #29255 See merge request !9936
-rw-r--r--app/helpers/users_helper.rb7
-rw-r--r--app/views/projects/pipelines/_info.html.haml10
-rw-r--r--changelogs/unreleased/tc-pipeline-show-trigger-date.yml4
-rw-r--r--spec/features/commits_spec.rb13
-rw-r--r--spec/features/projects/pipelines/pipeline_spec.rb2
-rw-r--r--spec/helpers/avatars_helper_spec.rb21
-rw-r--r--spec/helpers/users_helper_spec.rb17
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb10
8 files changed, 74 insertions, 10 deletions
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
new file mode 100644
index 00000000000..9c623c9ba7c
--- /dev/null
+++ b/app/helpers/users_helper.rb
@@ -0,0 +1,7 @@
+module UsersHelper
+ def user_link(user)
+ link_to(user.name, user_path(user),
+ title: user.email,
+ class: 'has-tooltip commit-committer-link')
+ end
+end
diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml
index 0605af4fcd3..4be9a1371ec 100644
--- a/app/views/projects/pipelines/_info.html.haml
+++ b/app/views/projects/pipelines/_info.html.haml
@@ -1,10 +1,12 @@
.page-content-header
.header-main-content
= render 'ci/status/badge', status: @pipeline.detailed_status(current_user)
- %strong Pipeline ##{@commit.pipelines.last.id}
- triggered #{time_ago_with_tooltip(@commit.authored_date)} by
- = author_avatar(@commit, size: 24)
- = commit_author_link(@commit)
+ %strong Pipeline ##{@pipeline.id}
+ triggered #{time_ago_with_tooltip(@pipeline.created_at)}
+ - if @pipeline.user
+ by
+ = user_avatar(user: @pipeline.user, size: 24)
+ = user_link(@pipeline.user)
.header-action-buttons
- if can?(current_user, :update_pipeline, @pipeline.project)
- if @pipeline.retryable?
diff --git a/changelogs/unreleased/tc-pipeline-show-trigger-date.yml b/changelogs/unreleased/tc-pipeline-show-trigger-date.yml
new file mode 100644
index 00000000000..4de784d98f3
--- /dev/null
+++ b/changelogs/unreleased/tc-pipeline-show-trigger-date.yml
@@ -0,0 +1,4 @@
+---
+title: Show correct user & creation time in heading of the pipeline page
+merge_request: 9936
+author:
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 0e305c52358..881f1fca4d1 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -11,12 +11,16 @@ describe 'Commits' do
stub_ci_pipeline_to_return_yaml_file
end
+ let(:creator) { create(:user) }
+
let!(:pipeline) do
create(:ci_pipeline,
project: project,
+ user: creator,
ref: project.default_branch,
sha: project.commit.sha,
- status: :success)
+ status: :success,
+ created_at: 5.months.ago)
end
context 'commit status is Generic Commit Status' do
@@ -80,7 +84,8 @@ describe 'Commits' do
it 'shows pipeline`s data' do
expect(page).to have_content pipeline.sha[0..7]
expect(page).to have_content pipeline.git_commit_message
- expect(page).to have_content pipeline.git_author_name
+ expect(page).to have_content pipeline.user.name
+ expect(page).to have_content pipeline.created_at.strftime('%b %d, %Y')
end
end
@@ -150,7 +155,7 @@ describe 'Commits' do
it do
expect(page).to have_content pipeline.sha[0..7]
expect(page).to have_content pipeline.git_commit_message
- expect(page).to have_content pipeline.git_author_name
+ expect(page).to have_content pipeline.user.name
expect(page).to have_link('Download artifacts')
expect(page).not_to have_link('Cancel running')
expect(page).not_to have_link('Retry')
@@ -169,7 +174,7 @@ describe 'Commits' do
it do
expect(page).to have_content pipeline.sha[0..7]
expect(page).to have_content pipeline.git_commit_message
- expect(page).to have_content pipeline.git_author_name
+ expect(page).to have_content pipeline.user.name
expect(page).not_to have_link('Download artifacts')
expect(page).not_to have_link('Cancel running')
expect(page).not_to have_link('Retry')
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index 9f06e52ab55..5a53e48f5f8 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -45,7 +45,7 @@ describe 'Pipeline', :feature, :js do
include_context 'pipeline builds'
let(:project) { create(:project) }
- let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
before { visit namespace_project_pipeline_path(project.namespace, project, pipeline) }
diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb
new file mode 100644
index 00000000000..581726c1d0e
--- /dev/null
+++ b/spec/helpers/avatars_helper_spec.rb
@@ -0,0 +1,21 @@
+require 'rails_helper'
+
+describe AvatarsHelper do
+ let(:user) { create(:user) }
+
+ describe '#user_avatar' do
+ subject { helper.user_avatar(user: user) }
+
+ it "links to the user's profile" do
+ is_expected.to include("href=\"#{user_path(user)}\"")
+ end
+
+ it "has the user's name as title" do
+ is_expected.to include("title=\"#{user.name}\"")
+ end
+
+ it "contains the user's avatar image" do
+ is_expected.to include(CGI.escapeHTML(user.avatar_url(16)))
+ end
+ end
+end
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
new file mode 100644
index 00000000000..03f78de8e91
--- /dev/null
+++ b/spec/helpers/users_helper_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+describe UsersHelper do
+ let(:user) { create(:user) }
+
+ describe '#user_link' do
+ subject { helper.user_link(user) }
+
+ it "links to the user's profile" do
+ is_expected.to include("href=\"#{user_path(user)}\"")
+ end
+
+ it "has the user's email as title" do
+ is_expected.to include("title=\"#{user.email}\"")
+ end
+ end
+end
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
index c101f6f164d..e4aeaeca508 100644
--- a/spec/views/projects/pipelines/show.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -3,8 +3,9 @@ require 'spec_helper'
describe 'projects/pipelines/show' do
include Devise::Test::ControllerHelpers
+ let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id) }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id, user: user) }
before do
controller.prepend_view_path('app/views/projects')
@@ -21,6 +22,7 @@ describe 'projects/pipelines/show' do
assign(:project, project)
assign(:pipeline, pipeline)
+ assign(:commit, project.commit)
allow(view).to receive(:can?).and_return(true)
end
@@ -31,6 +33,12 @@ describe 'projects/pipelines/show' do
expect(rendered).to have_css('.js-pipeline-graph')
expect(rendered).to have_css('.js-grouped-pipeline-dropdown')
+ # header
+ expect(rendered).to have_text("##{pipeline.id}")
+ expect(rendered).to have_css('time', text: pipeline.created_at.strftime("%b %d, %Y"))
+ expect(rendered).to have_selector(%Q(img[alt$="#{pipeline.user.name}'s avatar"]))
+ expect(rendered).to have_link(pipeline.user.name, href: user_path(pipeline.user))
+
# stages
expect(rendered).to have_text('Build')
expect(rendered).to have_text('Test')