diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-02-26 13:29:37 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-03-01 14:32:21 +0100 |
commit | 79a37423a34bb7e07e6b194feb0a515b7e7e965d (patch) | |
tree | 37aa1ce704e60e05b112450330240f2fac448457 /spec/views | |
parent | 86052e6cbbba8fd41f59e24230a20cd5d5e51954 (diff) | |
download | gitlab-ce-79a37423a34bb7e07e6b194feb0a515b7e7e965d.tar.gz |
Improve readability in CI/CD status badge view tests
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/ci/status/_badge.html.haml_spec.rb | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/spec/views/ci/status/_badge.html.haml_spec.rb b/spec/views/ci/status/_badge.html.haml_spec.rb index e1a33f5096e..04ee841da00 100644 --- a/spec/views/ci/status/_badge.html.haml_spec.rb +++ b/spec/views/ci/status/_badge.html.haml_spec.rb @@ -6,26 +6,29 @@ describe 'ci/status/_badge', :view do let(:pipeline) { create(:ci_pipeline, project: project) } context 'when rendering status for build' do - let(:resource) { create(:ci_build, :success, pipeline: pipeline) } - - let(:details_path) do - namespace_project_build_path(resource.project.namespace, - resource.project, - resource) + let(:build) do + create(:ci_build, :success, pipeline: pipeline) end context 'when status has details' do before do - user_with_role(:developer) { render_status } + project.add_developer(user) end it 'has link to build details page' do + details_path = namespace_project_build_path( + project.namespace, project, build) + + render_status(build) + expect(rendered).to have_link 'passed', href: details_path end end context 'when status does not have details' do - before { render_status } + before do + render_status(build) + end it 'contains build status text' do expect(rendered).to have_content 'passed' @@ -39,11 +42,13 @@ describe 'ci/status/_badge', :view do context 'when rendering status for external job' do before do - user_with_role(:developer) { render_status } + project.add_developer(use) + + render_status(external_job) end context 'status has external target url' do - let(:resource) do + let(:external_job) do create(:generic_commit_status, status: :running, pipeline: pipeline, target_url: 'http://gitlab.com') @@ -59,7 +64,7 @@ describe 'ci/status/_badge', :view do end context 'status do not have external target url' do - let(:resource) do + let(:external_job) do create(:generic_commit_status, status: :canceled) end @@ -73,13 +78,7 @@ describe 'ci/status/_badge', :view do end end - def render_status + def render_status(resource) render 'ci/status/badge', status: resource.detailed_status(user) end - - def user_with_role(role) - project.team << [user, role] - - yield if block_given? - end end |