summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-09-08 18:51:35 -0400
committerStan Hu <stanhu@gmail.com>2016-09-08 18:52:55 -0400
commitf12354916bf0531a1f2d7cffbc67d36fd425d088 (patch)
treece68789f4c395c413fec580e07d91a52bab66e83
parent65eadf98fe5b0dd3d5e860695981c4069ae20676 (diff)
downloadgitlab-ce-slash-commands-issuable-spec-fix.tar.gz
Move write_note into SlashCommandsHelper and update other dependent specsslash-commands-issuable-spec-fix
-rw-r--r--spec/features/issues/user_uses_slash_commands_spec.rb15
-rw-r--r--spec/features/merge_requests/user_uses_slash_commands_spec.rb10
-rw-r--r--spec/support/issuable_slash_commands_shared_examples.rb10
-rw-r--r--spec/support/slash_commands_helpers.rb10
4 files changed, 24 insertions, 21 deletions
diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb
index 2883e392694..105629c485a 100644
--- a/spec/features/issues/user_uses_slash_commands_spec.rb
+++ b/spec/features/issues/user_uses_slash_commands_spec.rb
@@ -1,6 +1,7 @@
require 'rails_helper'
feature 'Issues > User uses slash commands', feature: true, js: true do
+ include SlashCommandsHelpers
include WaitForAjax
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
visit namespace_project_issue_path(project.namespace, project, issue)
end
+ after do
+ wait_for_ajax
+ end
+
describe 'adding a due date from note' do
let(:issue) { create(:issue, project: project) }
it 'does not create a note, and sets the due date accordingly' do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/due 2016-08-28"
- click_button 'Comment'
- end
+ write_note("/due 2016-08-28")
expect(page).not_to have_content '/due 2016-08-28'
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
it 'does not create a note, and removes the due date accordingly' do
expect(issue.due_date).to eq Date.new(2016, 8, 28)
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/remove_due_date"
- click_button 'Comment'
- end
+ write_note("/remove_due_date")
expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Your commands have been executed!'
diff --git a/spec/features/merge_requests/user_uses_slash_commands_spec.rb b/spec/features/merge_requests/user_uses_slash_commands_spec.rb
index d9ef0d18074..22d9d1b9fd5 100644
--- a/spec/features/merge_requests/user_uses_slash_commands_spec.rb
+++ b/spec/features/merge_requests/user_uses_slash_commands_spec.rb
@@ -1,6 +1,7 @@
require 'rails_helper'
feature 'Merge Requests > User uses slash commands', feature: true, js: true do
+ include SlashCommandsHelpers
include WaitForAjax
let(:user) { create(:user) }
@@ -20,11 +21,12 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
+ after do
+ wait_for_ajax
+ end
+
it 'does not recognize the command nor create a note' do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/due 2016-08-28"
- click_button 'Comment'
- end
+ write_note("/due 2016-08-28")
expect(page).not_to have_content '/due 2016-08-28'
end
diff --git a/spec/support/issuable_slash_commands_shared_examples.rb b/spec/support/issuable_slash_commands_shared_examples.rb
index a3fbba55e27..5e3b8f2b23e 100644
--- a/spec/support/issuable_slash_commands_shared_examples.rb
+++ b/spec/support/issuable_slash_commands_shared_examples.rb
@@ -2,6 +2,7 @@
# 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|
+ include SlashCommandsHelpers
include WaitForAjax
let(:master) { create(:user) }
@@ -25,15 +26,6 @@ shared_examples 'issuable record that supports slash commands in its description
wait_for_ajax
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
context 'with commands in the description' do
it "creates the #{issuable_type} and interpret commands accordingly" do
diff --git a/spec/support/slash_commands_helpers.rb b/spec/support/slash_commands_helpers.rb
new file mode 100644
index 00000000000..df483afa0e3
--- /dev/null
+++ b/spec/support/slash_commands_helpers.rb
@@ -0,0 +1,10 @@
+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