Commit eae2ed33 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Spec improvements for speed, reliability and readability

parent 2bf3846a
...@@ -956,7 +956,7 @@ describe Projects::IssuesController do ...@@ -956,7 +956,7 @@ describe Projects::IssuesController do
end end
it 'is not available when the project is archived' do it 'is not available when the project is archived' do
project.update(archived: true) project.update!(archived: true)
create_merge_request create_merge_request
......
...@@ -37,7 +37,7 @@ describe 'Merge request > User awards emoji', :js do ...@@ -37,7 +37,7 @@ describe 'Merge request > User awards emoji', :js do
end end
describe 'the project is archived' do 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 it 'does not see award menu button' do
expect(page).not_to have_selector('.js-award-holder') expect(page).not_to have_selector('.js-award-holder')
......
...@@ -103,7 +103,7 @@ describe 'User interacts with awards in an issue', :js do ...@@ -103,7 +103,7 @@ describe 'User interacts with awards in an issue', :js do
end end
context 'when a project is archived' do 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 it 'hides the add award button' do
page.within('.awards') do page.within('.awards') do
...@@ -147,7 +147,7 @@ describe 'User interacts with awards in an issue', :js do ...@@ -147,7 +147,7 @@ describe 'User interacts with awards in an issue', :js do
end end
context 'when the project is archived' do 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 it 'hides the buttons for adding new emoji' do
page.within('.note-awards') do page.within('.note-awards') do
......
...@@ -205,7 +205,7 @@ describe 'Branches' do ...@@ -205,7 +205,7 @@ describe 'Branches' do
end end
context 'when the project is archived' do 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 it 'does not show the merge request button when the project is archived' do
visit project_branches_path(project) visit project_branches_path(project)
......
...@@ -91,11 +91,12 @@ describe 'Cherry-pick Commits' do ...@@ -91,11 +91,12 @@ describe 'Cherry-pick Commits' do
end end
context 'when the project is archived' do 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 it 'does not show the cherry-pick link' do
find('.header-action-buttons a.dropdown-toggle').click 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']") expect(page).not_to have_css("a[href='#modal-cherry-pick-commit']")
end end
end end
......
...@@ -62,7 +62,7 @@ describe 'User reverts a commit', :js do ...@@ -62,7 +62,7 @@ describe 'User reverts a commit', :js do
end end
context 'when the project is archived' do 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 it 'does not show the revert link' do
find('.header-action-buttons .dropdown').click find('.header-action-buttons .dropdown').click
......
...@@ -20,15 +20,11 @@ describe 'Projects > Files > User edits files' do ...@@ -20,15 +20,11 @@ describe 'Projects > Files > User edits files' do
click_link('.gitignore') click_link('.gitignore')
aggregate_failures 'available edit buttons' do aggregate_failures 'available edit buttons' do
# We're showing a link, if the user can edit directly, this is becomes a expect(page).not_to have_text('Edit')
# button when the user can fork the project. expect(page).not_to have_text('Web IDE')
expect(page).not_to have_link('Edit')
expect(page).not_to have_button('Edit') expect(page).not_to have_text('Replace')
expect(page).not_to have_link('Web IDE') expect(page).not_to have_text('Delete')
expect(page).not_to have_button('Web IDE')
expect(page).not_to have_button('Replace')
expect(page).not_to have_button('Delete')
end end
end end
end end
......
...@@ -14,19 +14,19 @@ describe "User views issue" do ...@@ -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_header_with_correct_id_and_link(1, "Description header", "description-header") }
it { expect(page).to have_link('New issue') } it 'shows the merge request and issue actions', :aggregate_failures do
expect(page).to have_link('New issue')
it { expect(page).to have_button('Create merge request') } expect(page).to have_button('Create merge request')
expect(page).to have_link('Close issue')
it { expect(page).to have_link('Close issue') } end
context 'when the project is archived' do context 'when the project is archived' do
let(:project) { create(:project, :public, archived: true) } let(:project) { create(:project, :public, :archived) }
it { expect(page).not_to have_link('New issue') }
it { expect(page).not_to have_button('Create merge request') }
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
end end
...@@ -100,7 +100,7 @@ describe 'User views open merge requests' do ...@@ -100,7 +100,7 @@ describe 'User views open merge requests' do
end end
context 'when the project is archived' do 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 it 'hides the new merge request button' do
expect(page).not_to have_link('New merge request') expect(page).not_to have_link('New merge request')
......
...@@ -7,7 +7,6 @@ describe 'projects/commit/_commit_box.html.haml' do ...@@ -7,7 +7,6 @@ describe 'projects/commit/_commit_box.html.haml' do
before do before do
assign(:project, project) assign(:project, project)
assign(:commit, project.commit) assign(:commit, project.commit)
assign(:current_user, user)
allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:can_collaborate_with_project?).and_return(false) allow(view).to receive(:can_collaborate_with_project?).and_return(false)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment