diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-06-19 21:06:13 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-06-19 21:06:13 -0500 |
commit | 2dac8f444cd5106d43f77c4946f64c3baccae13b (patch) | |
tree | 77a6ad9463c197d0a8033d9d0a6b07b1e4e6d3de /spec/features/issues_spec.rb | |
parent | 1c64fa08aeab7e56a4bef7da24840b12eb03b9ac (diff) | |
download | gitlab-ce-2dac8f444cd5106d43f77c4946f64c3baccae13b.tar.gz |
Remove implicit dependency on `gitlab_sign_in` assigning `@user`rs-login_as
We shouldn't be using instance variables in specs to begin with, and
depending on this implicit behavior of `gitlab_sign_in` would have made
it more difficult to change to `sign_in` where possible.
...we've also gone ahead and changed to `sign_in` where possible.
Diffstat (limited to 'spec/features/issues_spec.rb')
-rw-r--r-- | spec/features/issues_spec.rb | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index ea637018617..f47b89fd718 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -5,20 +5,21 @@ describe 'Issues', feature: true do include IssueHelpers include SortingHelper + let(:user) { create(:user) } let(:project) { create(:empty_project, :public) } before do - gitlab_sign_in :user + sign_in(user) user2 = create(:user) - project.team << [[@user, user2], :developer] + project.team << [[user, user2], :developer] end describe 'Edit issue' do let!(:issue) do create(:issue, - author: @user, - assignees: [@user], + author: user, + assignees: [user], project: project) end @@ -35,15 +36,15 @@ describe 'Issues', feature: true do describe 'Editing issue assignee' do let!(:issue) do create(:issue, - author: @user, - assignees: [@user], + author: user, + assignees: [user], project: project) end it 'allows user to select unassigned', js: true do visit edit_namespace_project_issue_path(project.namespace, project, issue) - expect(page).to have_content "Assignee #{@user.name}" + expect(page).to have_content "Assignee #{user.name}" first('.js-user-search').click click_link 'Unassigned' @@ -86,7 +87,7 @@ describe 'Issues', feature: true do end context 'on edit form' do - let(:issue) { create(:issue, author: @user, project: project, due_date: Date.today.at_beginning_of_month.to_s) } + let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) } before do visit edit_namespace_project_issue_path(project.namespace, project, issue) @@ -131,10 +132,10 @@ describe 'Issues', feature: true do describe 'Issue info' do it 'excludes award_emoji from comment count' do - issue = create(:issue, author: @user, assignees: [@user], project: project, title: 'foobar') + issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar') create(:award_emoji, awardable: issue) - visit namespace_project_issues_path(project.namespace, project, assignee_id: @user.id) + visit namespace_project_issues_path(project.namespace, project, assignee_id: user.id) expect(page).to have_content 'foobar' expect(page.all('.no-comments').first.text).to eq "0" @@ -145,8 +146,8 @@ describe 'Issues', feature: true do before do %w(foobar barbaz gitlab).each do |title| create(:issue, - author: @user, - assignees: [@user], + author: user, + assignees: [user], project: project, title: title) end @@ -168,7 +169,7 @@ describe 'Issues', feature: true do end it 'allows filtering by a specified assignee' do - visit namespace_project_issues_path(project.namespace, project, assignee_id: @user.id) + visit namespace_project_issues_path(project.namespace, project, assignee_id: user.id) expect(page).not_to have_content 'foobar' expect(page).to have_content 'barbaz' @@ -366,13 +367,13 @@ describe 'Issues', feature: true do end describe 'when I want to reset my incoming email token' do - let(:project1) { create(:empty_project, namespace: @user.namespace) } + let(:project1) { create(:empty_project, namespace: user.namespace) } let!(:issue) { create(:issue, project: project1) } before do stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab") - project1.team << [@user, :master] - visit namespace_project_issues_path(@user.namespace, project1) + project1.team << [user, :master] + visit namespace_project_issues_path(user.namespace, project1) end it 'changes incoming email address token', js: true do @@ -383,7 +384,7 @@ describe 'Issues', feature: true do wait_for_requests expect(page).to have_no_field('issue_email', with: previous_token) - new_token = project1.new_issue_address(@user.reload) + new_token = project1.new_issue_address(user.reload) expect(page).to have_field( 'issue_email', with: new_token @@ -392,7 +393,7 @@ describe 'Issues', feature: true do end describe 'update labels from issue#show', js: true do - let(:issue) { create(:issue, project: project, author: @user, assignees: [@user]) } + let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let!(:label) { create(:label, project: project) } before do @@ -411,14 +412,14 @@ describe 'Issues', feature: true do end describe 'update assignee from issue#show' do - let(:issue) { create(:issue, project: project, author: @user, assignees: [@user]) } + let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } context 'by authorized user' do it 'allows user to select unassigned', js: true do visit namespace_project_issue_path(project.namespace, project, issue) page.within('.assignee') do - expect(page).to have_content "#{@user.name}" + expect(page).to have_content "#{user.name}" click_link 'Edit' click_link 'Unassigned' @@ -433,7 +434,7 @@ describe 'Issues', feature: true do end it 'allows user to select an assignee', js: true do - issue2 = create(:issue, project: project, author: @user) + issue2 = create(:issue, project: project, author: user) visit namespace_project_issue_path(project.namespace, project, issue2) page.within('.assignee') do @@ -445,28 +446,28 @@ describe 'Issues', feature: true do end page.within '.dropdown-menu-user' do - click_link @user.name + click_link user.name end page.within('.assignee') do - expect(page).to have_content @user.name + expect(page).to have_content user.name end end it 'allows user to unselect themselves', js: true do - issue2 = create(:issue, project: project, author: @user) + issue2 = create(:issue, project: project, author: user) visit namespace_project_issue_path(project.namespace, project, issue2) page.within '.assignee' do click_link 'Edit' - click_link @user.name + click_link user.name page.within '.value .author' do - expect(page).to have_content @user.name + expect(page).to have_content user.name end click_link 'Edit' - click_link @user.name + click_link user.name page.within '.value .assign-yourself' do expect(page).to have_content "No assignee" @@ -483,8 +484,8 @@ describe 'Issues', feature: true do end it 'shows assignee text', js: true do - gitlab_sign_out - gitlab_sign_in guest + sign_out(:user) + sign_in(guest) visit namespace_project_issue_path(project.namespace, project, issue) expect(page).to have_content issue.assignees.first.name @@ -493,7 +494,7 @@ describe 'Issues', feature: true do end describe 'update milestone from issue#show' do - let!(:issue) { create(:issue, project: project, author: @user) } + let!(:issue) { create(:issue, project: project, author: user) } let!(:milestone) { create(:milestone, project: project) } context 'by authorized user' do @@ -546,8 +547,8 @@ describe 'Issues', feature: true do end it 'shows milestone text', js: true do - gitlab_sign_out - gitlab_sign_in guest + sign_out(:user) + sign_in(guest) visit namespace_project_issue_path(project.namespace, project, issue) expect(page).to have_content milestone.title @@ -560,7 +561,7 @@ describe 'Issues', feature: true do context 'by unauthenticated user' do before do - gitlab_sign_out + sign_out(:user) end it 'redirects to signin then back to new issue after signin' do @@ -570,7 +571,9 @@ describe 'Issues', feature: true do expect(current_path).to eq new_user_session_path - gitlab_sign_in :user + # NOTE: This is specifically testing the redirect after login, so we + # need the full login flow + gitlab_sign_in(create(:user)) expect(current_path).to eq new_namespace_project_issue_path(project.namespace, project) end @@ -599,7 +602,7 @@ describe 'Issues', feature: true do before do project.repository.create_file( - @user, + user, '.gitlab/issue_templates/bug.md', 'this is a test "bug" template', message: 'added issue template', @@ -628,7 +631,7 @@ describe 'Issues', feature: true do it 'click the button to show modal for the new email' do page.within '#issue-email-modal' do - email = project.new_issue_address(@user) + email = project.new_issue_address(user) expect(page).to have_selector("input[value='#{email}']") end @@ -636,7 +639,7 @@ describe 'Issues', feature: true do end context 'with existing issues' do - let!(:issue) { create(:issue, project: project, author: @user) } + let!(:issue) { create(:issue, project: project, author: user) } it_behaves_like 'show the email in the modal' end @@ -648,7 +651,7 @@ describe 'Issues', feature: true do describe 'due date' do context 'update due on issue#show', js: true do - let(:issue) { create(:issue, project: project, author: @user, assignees: [@user]) } + let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } before do visit namespace_project_issue_path(project.namespace, project, issue) @@ -693,7 +696,7 @@ describe 'Issues', feature: true do describe 'title issue#show', js: true do it 'updates the title', js: true do - issue = create(:issue, author: @user, assignees: [@user], project: project, title: 'new title') + issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title') visit namespace_project_issue_path(project.namespace, project, issue) |