summaryrefslogtreecommitdiff
path: root/spec/support/features
diff options
context:
space:
mode:
authorMehdi Lahmam <mehdi@lahmam.com>2017-11-05 23:52:39 +0100
committerMehdi Lahmam <mehdi@lahmam.com>2018-09-06 22:39:19 +0200
commit60bf55456edb3e06ba57dd1da20dffb5d0bfead7 (patch)
tree4e940c7ed408d04000cdf7b00b6c64a5e5159076 /spec/support/features
parent051007498d553d16172120b2ab7a79d0f244545c (diff)
downloadgitlab-ce-60bf55456edb3e06ba57dd1da20dffb5d0bfead7.tar.gz
Add /lock and /unlock quick actions
Closes #39173
Diffstat (limited to 'spec/support/features')
-rw-r--r--spec/support/features/issuable_slash_commands_shared_examples.rb74
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/support/features/issuable_slash_commands_shared_examples.rb b/spec/support/features/issuable_slash_commands_shared_examples.rb
index 9b44c532ff6..f19ba3c5cf9 100644
--- a/spec/support/features/issuable_slash_commands_shared_examples.rb
+++ b/spec/support/features/issuable_slash_commands_shared_examples.rb
@@ -285,6 +285,80 @@ shared_examples 'issuable record that supports quick actions in its description
expect(issuable.reload.assignees).to eq [maintainer]
end
end
+
+ context "with a note locking the #{issuable_type} discussion" do
+ before do
+ issuable.update(discussion_locked: false)
+ expect(issuable).not_to be_discussion_locked
+ end
+
+ context "when current user can lock #{issuable_type} discussion" do
+ it "locks the #{issuable_type} discussion" do
+ add_note("/lock")
+
+ expect(page).not_to have_content '/lock'
+ expect(page).to have_content 'Commands applied'
+
+ expect(issuable.reload).to be_discussion_locked
+ end
+ end
+
+ context "when current user cannot lock #{issuable_type}" do
+ before do
+ guest = create(:user)
+ project.add_guest(guest)
+
+ gitlab_sign_out
+ gitlab_sign_in(guest)
+ visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
+ end
+
+ it "does not lock the #{issuable_type} discussion" do
+ add_note("/lock")
+
+ expect(page).not_to have_content 'Commands applied'
+
+ expect(issuable).not_to be_discussion_locked
+ end
+ end
+ end
+
+ context "with a note unlocking the #{issuable_type} discussion" do
+ before do
+ issuable.update(discussion_locked: true)
+ expect(issuable).to be_discussion_locked
+ end
+
+ context "when current user can unlock #{issuable_type} discussion" do
+ it "unlocks the #{issuable_type} discussion" do
+ add_note("/unlock")
+
+ expect(page).not_to have_content '/unlock'
+ expect(page).to have_content 'Commands applied'
+
+ expect(issuable.reload).not_to be_discussion_locked
+ end
+ end
+
+ context "when current user cannot unlock #{issuable_type}" do
+ before do
+ guest = create(:user)
+ project.add_guest(guest)
+
+ gitlab_sign_out
+ gitlab_sign_in(guest)
+ visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
+ end
+
+ it "does not unlock the #{issuable_type} discussion" do
+ add_note("/unlock")
+
+ expect(page).not_to have_content 'Commands applied'
+
+ expect(issuable).to be_discussion_locked
+ end
+ end
+ end
end
describe "preview of note on #{issuable_type}", :js do