diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-10 11:39:30 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-05-10 11:39:30 +1100 |
commit | 5373a5b18f253e286decaabb6239a69b26e3fdbd (patch) | |
tree | 8d94c1583698637b0f9105d3aee861550d4b4087 | |
parent | 0d77be076d2a041f55ea23a7202eb0bcf801a8f2 (diff) | |
download | gitlab-ce-5373a5b18f253e286decaabb6239a69b26e3fdbd.tar.gz |
Replace `features/project/merge_requests/references.featue`blackst0ne-replace-spinach-project-merge-requests-references.feature
-rw-r--r-- | features/project/merge_requests/references.feature | 31 | ||||
-rw-r--r-- | features/steps/shared/authentication.rb | 12 | ||||
-rw-r--r-- | features/steps/shared/issuable.rb | 61 | ||||
-rw-r--r-- | features/steps/shared/note.rb | 4 | ||||
-rw-r--r-- | features/steps/shared/project.rb | 23 | ||||
-rw-r--r-- | spec/features/issuables/markdown_references/internal_references_spec.rb | 60 |
6 files changed, 60 insertions, 131 deletions
diff --git a/features/project/merge_requests/references.feature b/features/project/merge_requests/references.feature deleted file mode 100644 index 571612261a9..00000000000 --- a/features/project/merge_requests/references.feature +++ /dev/null @@ -1,31 +0,0 @@ -@project_merge_requests -Feature: Project Merge Requests References - Background: - Given I sign in as "John Doe" - And public project "Community" - And "John Doe" owns public project "Community" - And project "Community" has "Community fix" open merge request - And I logout - And I sign in as "Mary Jane" - And private project "Enterprise" - And "Mary Jane" owns private project "Enterprise" - And project "Enterprise" has "Enterprise issue" open issue - And project "Enterprise" has "Enterprise fix" open merge request - And I visit issue page "Enterprise issue" - And I leave a comment referencing issue "Community fix" - And I visit merge request page "Enterprise fix" - And I leave a comment referencing issue "Community fix" - And I logout - - @javascript - Scenario: Viewing the public issue as a "John Doe" - Given I sign in as "John Doe" - When I visit issue page "Community fix" - Then I should see no notes at all - - @javascript - Scenario: Viewing the public issue as "Mary Jane" - Given I sign in as "Mary Jane" - When I visit issue page "Community fix" - And I should see a note linking to "Enterprise fix" merge request - And I should see a note linking to "Enterprise issue" issue diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 97fac595d8e..27dd391b83d 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -22,22 +22,10 @@ module SharedAuthentication sign_in(@user) end - step 'I sign in as "John Doe"' do - gitlab_sign_in(user_exists("John Doe")) - end - - step 'I sign in as "Mary Jane"' do - gitlab_sign_in(user_exists("Mary Jane")) - end - step 'I should be redirected to sign in page' do expect(current_path).to eq new_user_session_path end - step "I logout" do - gitlab_sign_out - end - step "I logout directly" do gitlab_sign_out end diff --git a/features/steps/shared/issuable.rb b/features/steps/shared/issuable.rb index 8d9cd3db9d9..cc6fd48935f 100644 --- a/features/steps/shared/issuable.rb +++ b/features/steps/shared/issuable.rb @@ -5,29 +5,6 @@ module SharedIssuable find('.js-issuable-edit', visible: true).click end - step 'project "Community" has "Community fix" open merge request' do - create_issuable_for_project( - project_name: 'Community', - type: :merge_request, - title: 'Community fix' - ) - end - - step 'project "Enterprise" has "Enterprise issue" open issue' do - create_issuable_for_project( - project_name: 'Enterprise', - title: 'Enterprise issue' - ) - end - - step 'project "Enterprise" has "Enterprise fix" open merge request' do - create_issuable_for_project( - project_name: 'Enterprise', - type: :merge_request, - title: 'Enterprise fix' - ) - end - step 'I leave a comment referencing issue "Community issue"' do leave_reference_comment( issuable: Issue.find_by(title: 'Community issue'), @@ -35,44 +12,6 @@ module SharedIssuable ) end - step 'I leave a comment referencing issue "Community fix"' do - leave_reference_comment( - issuable: MergeRequest.find_by(title: 'Community fix'), - from_project_name: 'Enterprise' - ) - end - - step 'I visit issue page "Enterprise issue"' do - issue = Issue.find_by(title: 'Enterprise issue') - visit project_issue_path(issue.project, issue) - end - - step 'I visit merge request page "Enterprise fix"' do - mr = MergeRequest.find_by(title: 'Enterprise fix') - visit project_merge_request_path(mr.target_project, mr) - end - - step 'I visit issue page "Community fix"' do - mr = MergeRequest.find_by(title: 'Community fix') - visit project_merge_request_path(mr.target_project, mr) - end - - step 'I should see a note linking to "Enterprise fix" merge request' do - visible_note( - issuable: MergeRequest.find_by(title: 'Enterprise fix'), - from_project_name: 'Community', - user_name: 'Mary Jane' - ) - end - - step 'I should see a note linking to "Enterprise issue" issue' do - visible_note( - issuable: Issue.find_by(title: 'Enterprise issue'), - from_project_name: 'Community', - user_name: 'Mary Jane' - ) - end - step 'I click link "Edit" for the merge request' do edit_issuable end diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index bf1b88c60d7..4a6dee3c7b8 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -18,8 +18,4 @@ module SharedNote expect(find('.js-md-preview')).to have_content('Nothing to preview.') end end - - step 'I should see no notes at all' do - expect(page).not_to have_css('.note') - end end diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index a1945cf5f3d..dbfb90fcc48 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -42,10 +42,6 @@ module SharedProject # Visibility level # ---------------------------------------- - step 'private project "Enterprise"' do - create(:project, :private, :repository, name: 'Enterprise') - end - step 'I should see project "Enterprise"' do expect(page).to have_content "Enterprise" end @@ -70,10 +66,6 @@ module SharedProject end end - step 'public project "Community"' do - create(:project, :public, :repository, name: 'Community') - end - step 'I should see project "Community"' do expect(page).to have_content "Community" end @@ -89,13 +81,6 @@ module SharedProject ) end - step '"Mary Jane" owns private project "Enterprise"' do - user_owns_project( - user_name: 'Mary Jane', - project_name: 'Enterprise' - ) - end - step '"John Doe" owns internal project "Internal"' do user_owns_project( user_name: 'John Doe', @@ -104,14 +89,6 @@ module SharedProject ) end - step '"John Doe" owns public project "Community"' do - user_owns_project( - user_name: 'John Doe', - project_name: 'Community', - visibility: :public - ) - end - step 'public empty project "Empty Public Project"' do create :project_empty_repo, :public, name: "Empty Public Project" end diff --git a/spec/features/issuables/markdown_references/internal_references_spec.rb b/spec/features/issuables/markdown_references/internal_references_spec.rb index 8af4b157cd8..9613e22bf24 100644 --- a/spec/features/issuables/markdown_references/internal_references_spec.rb +++ b/spec/features/issuables/markdown_references/internal_references_spec.rb @@ -10,6 +10,7 @@ describe "Internal references", :js do let(:public_project_user) { public_project.owner } let(:public_project) { create(:project, :public, :repository) } let(:public_project_issue) { create(:issue, project: public_project) } + let(:public_project_merge_request) { create(:merge_request, source_project: public_project) } context "when referencing to open issue" do context "from private project" do @@ -77,4 +78,63 @@ describe "Internal references", :js do end end end + + context "when referencing to open merge request" do + context "from private project" do + context "from issue" do + before do + sign_in(private_project_user) + + visit(project_issue_path(private_project, private_project_issue)) + + add_note("##{public_project_merge_request.to_reference(private_project)}") + end + + context "when user doesn't have access to private project" do + before do + sign_in(public_project_user) + + visit(project_merge_request_path(public_project, public_project_merge_request)) + end + + it { expect(page).not_to have_css(".note") } + end + end + + context "from merge request" do + before do + sign_in(private_project_user) + + visit(project_merge_request_path(private_project, private_project_merge_request)) + + add_note("##{public_project_merge_request.to_reference(private_project)}") + end + + context "when user doesn't have access to private project" do + before do + sign_in(public_project_user) + + visit(project_merge_request_path(public_project, public_project_merge_request)) + end + + it "doesn't show any references" do + page.within(".merge-request-details") do + expect(page).not_to have_content("#merge-requests .merge-requests-title") + end + end + end + + context "when user has access to private project" do + before do + visit(project_merge_request_path(public_project, public_project_merge_request)) + end + + it "shows references" do + expect(page).to have_content("mentioned in merge request #{private_project_merge_request.to_reference(public_project)}") + .and have_content(private_project_user.name) + end + end + end + end + end end |