diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-12 00:14:02 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-12 19:05:50 +0300 |
commit | eae2ed3366ac13832c56aefe965513b986d7e8b1 (patch) | |
tree | 12fa2cb1bac9ab03c1476f5c58f215aaf0a7ba10 /spec | |
parent | 2bf3846adcac843958837a32fafdeb63d067a532 (diff) |
Spec improvements for speed, reliability and readability
Diffstat (limited to 'spec')
10 files changed, 25 insertions, 29 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 6c6b1e4a500..ca86b0bc737 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -956,7 +956,7 @@ describe Projects::IssuesController do end it 'is not available when the project is archived' do - project.update(archived: true) + project.update!(archived: true) create_merge_request diff --git a/spec/features/merge_request/user_awards_emoji_spec.rb b/spec/features/merge_request/user_awards_emoji_spec.rb index fa254e8c6c5..859a4c65562 100644 --- a/spec/features/merge_request/user_awards_emoji_spec.rb +++ b/spec/features/merge_request/user_awards_emoji_spec.rb @@ -37,7 +37,7 @@ describe 'Merge request > User awards emoji', :js do end describe 'the project is archived' do - let(:project) { create(:project, :public, :repository, archived: true) } + let(:project) { create(:project, :public, :repository, :archived) } it 'does not see award menu button' do expect(page).not_to have_selector('.js-award-holder') diff --git a/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb b/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb index a4890b34208..12e07647ecd 100644 --- a/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb +++ b/spec/features/projects/awards/user_interacts_with_awards_in_issue_spec.rb @@ -103,7 +103,7 @@ describe 'User interacts with awards in an issue', :js do end context 'when a project is archived' do - let(:project) { create(:project, archived: true) } + let(:project) { create(:project, :archived) } it 'hides the add award button' do page.within('.awards') do @@ -147,7 +147,7 @@ describe 'User interacts with awards in an issue', :js do end context 'when the project is archived' do - let(:project) { create(:project, archived: true) } + let(:project) { create(:project, :archived) } it 'hides the buttons for adding new emoji' do page.within('.note-awards') do diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index acf478cd117..b7ce1b9993a 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -205,7 +205,7 @@ describe 'Branches' do end context 'when the project is archived' do - let(:project) { create(:project, :public, :repository, archived: true) } + let(:project) { create(:project, :public, :repository, :archived) } it 'does not show the merge request button when the project is archived' do visit project_branches_path(project) diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb index 2f9d4f67488..1df45865d6f 100644 --- a/spec/features/projects/commit/cherry_pick_spec.rb +++ b/spec/features/projects/commit/cherry_pick_spec.rb @@ -91,11 +91,12 @@ describe 'Cherry-pick Commits' do end context 'when the project is archived' do - let(:project) { create(:project, :repository, namespace: group, archived: true) } + let(:project) { create(:project, :repository, :archived, namespace: group) } it 'does not show the cherry-pick link' do find('.header-action-buttons a.dropdown-toggle').click + expect(page).not_to have_text("Cherry-pick") expect(page).not_to have_css("a[href='#modal-cherry-pick-commit']") end end diff --git a/spec/features/projects/commit/user_reverts_commit_spec.rb b/spec/features/projects/commit/user_reverts_commit_spec.rb index 5a09e2380b6..42844a03ea6 100644 --- a/spec/features/projects/commit/user_reverts_commit_spec.rb +++ b/spec/features/projects/commit/user_reverts_commit_spec.rb @@ -62,7 +62,7 @@ describe 'User reverts a commit', :js do end context 'when the project is archived' do - let(:project) { create(:project, :repository, namespace: user.namespace, archived: true) } + let(:project) { create(:project, :repository, :archived, namespace: user.namespace) } it 'does not show the revert link' do find('.header-action-buttons .dropdown').click diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index ee9deb30890..dc6e4fd27cb 100644 --- a/spec/features/projects/files/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -20,15 +20,11 @@ describe 'Projects > Files > User edits files' do click_link('.gitignore') aggregate_failures 'available edit buttons' do - # We're showing a link, if the user can edit directly, this is becomes a - # button when the user can fork the project. - expect(page).not_to have_link('Edit') - expect(page).not_to have_button('Edit') - expect(page).not_to have_link('Web IDE') - expect(page).not_to have_button('Web IDE') - - expect(page).not_to have_button('Replace') - expect(page).not_to have_button('Delete') + expect(page).not_to have_text('Edit') + expect(page).not_to have_text('Web IDE') + + expect(page).not_to have_text('Replace') + expect(page).not_to have_text('Delete') end end end diff --git a/spec/features/projects/issues/user_views_issue_spec.rb b/spec/features/projects/issues/user_views_issue_spec.rb index d17ce636f3b..4093876c289 100644 --- a/spec/features/projects/issues/user_views_issue_spec.rb +++ b/spec/features/projects/issues/user_views_issue_spec.rb @@ -14,19 +14,19 @@ describe "User views issue" do it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") } - it { expect(page).to have_link('New issue') } - - it { expect(page).to have_button('Create merge request') } - - it { expect(page).to have_link('Close issue') } + it 'shows the merge request and issue actions', :aggregate_failures do + expect(page).to have_link('New issue') + expect(page).to have_button('Create merge request') + expect(page).to have_link('Close issue') + end context 'when the project is archived' do - let(:project) { create(:project, :public, archived: true) } - - it { expect(page).not_to have_link('New issue') } - - it { expect(page).not_to have_button('Create merge request') } + let(:project) { create(:project, :public, :archived) } - it { expect(page).not_to have_link('Close issue') } + it 'hides the merge request and issue actions', :aggregate_failures do + expect(page).not_to have_link('New issue') + expect(page).not_to have_button('Create merge request') + expect(page).not_to have_link('Close issue') + end end end diff --git a/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb b/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb index 08826625842..115e548b691 100644 --- a/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb +++ b/spec/features/projects/merge_requests/user_views_open_merge_requests_spec.rb @@ -100,7 +100,7 @@ describe 'User views open merge requests' do end context 'when the project is archived' do - let(:project) { create(:project, :public, :repository, archived: true) } + let(:project) { create(:project, :public, :repository, :archived) } it 'hides the new merge request button' do expect(page).not_to have_link('New merge request') diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb index fb5087f5090..2fdd28a3be4 100644 --- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb +++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb @@ -7,7 +7,6 @@ describe 'projects/commit/_commit_box.html.haml' do before do assign(:project, project) assign(:commit, project.commit) - assign(:current_user, user) allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:can_collaborate_with_project?).and_return(false) end |