Commit 22ee3f54 authored by Stan Hu's avatar Stan Hu

Fix spec failures with spec/features/issues/user_uses_slash_commands_spec.rb

Sidekiq async tasks were being run after project namespaces were deleted. Use
Sidekiq in fake mode to prevent this from Sidekiq tasks from being enqueued
in the first place.

Closes #21723
parent 796bdf1d
...@@ -18,6 +18,15 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -18,6 +18,15 @@ shared_examples 'issuable record that supports slash commands in its description
login_with(master) login_with(master)
end end
def write_note(text)
Sidekiq::Testing.fake! do
page.within('.js-main-target-form') do
fill_in 'note[note]', with: text
click_button 'Comment'
end
end
end
describe "new #{issuable_type}" do describe "new #{issuable_type}" do
context 'with commands in the description' do context 'with commands in the description' do
it "creates the #{issuable_type} and interpret commands accordingly" do it "creates the #{issuable_type} and interpret commands accordingly" do
...@@ -44,10 +53,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -44,10 +53,7 @@ shared_examples 'issuable record that supports slash commands in its description
context 'with a note containing commands' do context 'with a note containing commands' do
it 'creates a note without the commands and interpret the commands accordingly' do it 'creates a note without the commands and interpret the commands accordingly' do
page.within('.js-main-target-form') do write_note("Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
fill_in 'note[note]', with: "Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\""
click_button 'Comment'
end
expect(page).to have_content 'Awesome!' expect(page).to have_content 'Awesome!'
expect(page).not_to have_content '/assign @bob' expect(page).not_to have_content '/assign @bob'
...@@ -66,10 +72,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -66,10 +72,7 @@ shared_examples 'issuable record that supports slash commands in its description
context 'with a note containing only commands' do context 'with a note containing only commands' do
it 'does not create a note but interpret the commands accordingly' do it 'does not create a note but interpret the commands accordingly' do
page.within('.js-main-target-form') do write_note("/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
fill_in 'note[note]', with: "/assign @bob\n/label ~bug\n/milestone %\"ASAP\""
click_button 'Comment'
end
expect(page).not_to have_content '/assign @bob' expect(page).not_to have_content '/assign @bob'
expect(page).not_to have_content '/label ~bug' expect(page).not_to have_content '/label ~bug'
...@@ -92,10 +95,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -92,10 +95,7 @@ shared_examples 'issuable record that supports slash commands in its description
context "when current user can close #{issuable_type}" do context "when current user can close #{issuable_type}" do
it "closes the #{issuable_type}" do it "closes the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/close")
fill_in 'note[note]', with: "/close"
click_button 'Comment'
end
expect(page).not_to have_content '/close' expect(page).not_to have_content '/close'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -112,10 +112,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -112,10 +112,7 @@ shared_examples 'issuable record that supports slash commands in its description
end end
it "does not close the #{issuable_type}" do it "does not close the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/close")
fill_in 'note[note]', with: "/close"
click_button 'Comment'
end
expect(page).not_to have_content '/close' expect(page).not_to have_content '/close'
expect(page).not_to have_content 'Your commands have been executed!' expect(page).not_to have_content 'Your commands have been executed!'
...@@ -133,10 +130,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -133,10 +130,7 @@ shared_examples 'issuable record that supports slash commands in its description
context "when current user can reopen #{issuable_type}" do context "when current user can reopen #{issuable_type}" do
it "reopens the #{issuable_type}" do it "reopens the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/reopen")
fill_in 'note[note]', with: "/reopen"
click_button 'Comment'
end
expect(page).not_to have_content '/reopen' expect(page).not_to have_content '/reopen'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -153,10 +147,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -153,10 +147,7 @@ shared_examples 'issuable record that supports slash commands in its description
end end
it "does not reopen the #{issuable_type}" do it "does not reopen the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/reopen")
fill_in 'note[note]', with: "/reopen"
click_button 'Comment'
end
expect(page).not_to have_content '/reopen' expect(page).not_to have_content '/reopen'
expect(page).not_to have_content 'Your commands have been executed!' expect(page).not_to have_content 'Your commands have been executed!'
...@@ -169,10 +160,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -169,10 +160,7 @@ shared_examples 'issuable record that supports slash commands in its description
context "with a note changing the #{issuable_type}'s title" do context "with a note changing the #{issuable_type}'s title" do
context "when current user can change title of #{issuable_type}" do context "when current user can change title of #{issuable_type}" do
it "reopens the #{issuable_type}" do it "reopens the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/title Awesome new title")
fill_in 'note[note]', with: "/title Awesome new title"
click_button 'Comment'
end
expect(page).not_to have_content '/title' expect(page).not_to have_content '/title'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -189,10 +177,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -189,10 +177,7 @@ shared_examples 'issuable record that supports slash commands in its description
end end
it "does not reopen the #{issuable_type}" do it "does not reopen the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/title Awesome new title")
fill_in 'note[note]', with: "/title Awesome new title"
click_button 'Comment'
end
expect(page).not_to have_content '/title' expect(page).not_to have_content '/title'
expect(page).not_to have_content 'Your commands have been executed!' expect(page).not_to have_content 'Your commands have been executed!'
...@@ -204,10 +189,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -204,10 +189,7 @@ shared_examples 'issuable record that supports slash commands in its description
context "with a note marking the #{issuable_type} as todo" do context "with a note marking the #{issuable_type} as todo" do
it "creates a new todo for the #{issuable_type}" do it "creates a new todo for the #{issuable_type}" do
page.within('.js-main-target-form') do write_note("/todo")
fill_in 'note[note]', with: "/todo"
click_button 'Comment'
end
expect(page).not_to have_content '/todo' expect(page).not_to have_content '/todo'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -238,10 +220,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -238,10 +220,7 @@ shared_examples 'issuable record that supports slash commands in its description
expect(todo.author).to eq master expect(todo.author).to eq master
expect(todo.user).to eq master expect(todo.user).to eq master
page.within('.js-main-target-form') do write_note("/done")
fill_in 'note[note]', with: "/done"
click_button 'Comment'
end
expect(page).not_to have_content '/done' expect(page).not_to have_content '/done'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -254,10 +233,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -254,10 +233,7 @@ shared_examples 'issuable record that supports slash commands in its description
it "creates a new todo for the #{issuable_type}" do it "creates a new todo for the #{issuable_type}" do
expect(issuable.subscribed?(master)).to be_falsy expect(issuable.subscribed?(master)).to be_falsy
page.within('.js-main-target-form') do write_note("/subscribe")
fill_in 'note[note]', with: "/subscribe"
click_button 'Comment'
end
expect(page).not_to have_content '/subscribe' expect(page).not_to have_content '/subscribe'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -274,10 +250,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -274,10 +250,7 @@ shared_examples 'issuable record that supports slash commands in its description
it "creates a new todo for the #{issuable_type}" do it "creates a new todo for the #{issuable_type}" do
expect(issuable.subscribed?(master)).to be_truthy expect(issuable.subscribed?(master)).to be_truthy
page.within('.js-main-target-form') do write_note("/unsubscribe")
fill_in 'note[note]', with: "/unsubscribe"
click_button 'Comment'
end
expect(page).not_to have_content '/unsubscribe' expect(page).not_to have_content '/unsubscribe'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
......
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