Commit f1235491 authored by Stan Hu's avatar Stan Hu

Move write_note into SlashCommandsHelper and update other dependent specs

parent 65eadf98
require 'rails_helper' require 'rails_helper'
feature 'Issues > User uses slash commands', feature: true, js: true do feature 'Issues > User uses slash commands', feature: true, js: true do
include SlashCommandsHelpers
include WaitForAjax include WaitForAjax
it_behaves_like 'issuable record that supports slash commands in its description and notes', :issue do it_behaves_like 'issuable record that supports slash commands in its description and notes', :issue do
...@@ -17,14 +18,15 @@ feature 'Issues > User uses slash commands', feature: true, js: true do ...@@ -17,14 +18,15 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
visit namespace_project_issue_path(project.namespace, project, issue) visit namespace_project_issue_path(project.namespace, project, issue)
end end
after do
wait_for_ajax
end
describe 'adding a due date from note' do describe 'adding a due date from note' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
it 'does not create a note, and sets the due date accordingly' do it 'does not create a note, and sets the due date accordingly' do
page.within('.js-main-target-form') do write_note("/due 2016-08-28")
fill_in 'note[note]', with: "/due 2016-08-28"
click_button 'Comment'
end
expect(page).not_to have_content '/due 2016-08-28' expect(page).not_to have_content '/due 2016-08-28'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
...@@ -41,10 +43,7 @@ feature 'Issues > User uses slash commands', feature: true, js: true do ...@@ -41,10 +43,7 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
it 'does not create a note, and removes the due date accordingly' do it 'does not create a note, and removes the due date accordingly' do
expect(issue.due_date).to eq Date.new(2016, 8, 28) expect(issue.due_date).to eq Date.new(2016, 8, 28)
page.within('.js-main-target-form') do write_note("/remove_due_date")
fill_in 'note[note]', with: "/remove_due_date"
click_button 'Comment'
end
expect(page).not_to have_content '/remove_due_date' expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Your commands have been executed!' expect(page).to have_content 'Your commands have been executed!'
......
require 'rails_helper' require 'rails_helper'
feature 'Merge Requests > User uses slash commands', feature: true, js: true do feature 'Merge Requests > User uses slash commands', feature: true, js: true do
include SlashCommandsHelpers
include WaitForAjax include WaitForAjax
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -20,12 +21,13 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do ...@@ -20,12 +21,13 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
visit namespace_project_merge_request_path(project.namespace, project, merge_request) visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end end
it 'does not recognize the command nor create a note' do after do
page.within('.js-main-target-form') do wait_for_ajax
fill_in 'note[note]', with: "/due 2016-08-28"
click_button 'Comment'
end end
it 'does not recognize the command nor create a note' do
write_note("/due 2016-08-28")
expect(page).not_to have_content '/due 2016-08-28' expect(page).not_to have_content '/due 2016-08-28'
end end
end end
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# It takes a `issuable_type`, and expect an `issuable`. # It takes a `issuable_type`, and expect an `issuable`.
shared_examples 'issuable record that supports slash commands in its description and notes' do |issuable_type| shared_examples 'issuable record that supports slash commands in its description and notes' do |issuable_type|
include SlashCommandsHelpers
include WaitForAjax include WaitForAjax
let(:master) { create(:user) } let(:master) { create(:user) }
...@@ -25,15 +26,6 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -25,15 +26,6 @@ shared_examples 'issuable record that supports slash commands in its description
wait_for_ajax wait_for_ajax
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
......
module SlashCommandsHelpers
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
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