Merge branch 'slash-commands-issuable-spec-fix' into 'master'
Fix intermittent spec failures with spec/features/issues/user_uses_slash_commands_spec.rb
This MR solves the intermittent spec failure:
```
1) Issues > User uses slash commands behaves like issuable record that supports slash commands in its description and notes note on issue with a note changing the issue's title when current user cannot change title of issue does not reopen the issue
Failure/Error: Gitlab::Routing.url_helpers.namespace_project_url(self.namespace, self)
ActionController::UrlGenerationError:
No route matches {:action=>"show", :controller=>"projects", :id=>#<Project id: 1, name: "project135", path: "gitlabhq", description: nil, created_at: "2016-08-31 20:45:48", updated_at: "2016-08-31 20:45:48", creator_id: 2, issues_enabled: true, merge_requests_enabled: true, wiki_enabled: true, namespace_id: 2, snippets_enabled: true, last_activity_at: "2016-08-31 20:45:48", import_url: nil, visibility_level: 20, archived: false, avatar: nil, import_status: "none", repository_size: 0.0, star_count: 0, import_type: nil, import_source: nil, commit_count: 0, import_error: nil, ci_id: nil, builds_enabled: true, shared_runners_enabled: true, runners_token: "_rNZHgsHzaDWGbyL3L2F", build_coverage_regex: nil, build_allow_git_fetch: true, build_timeout: 3600, pending_delete: false, public_builds: true, pushes_since_gc: 0, last_repository_check_failed: nil, last_repository_check_at: nil, container_registry_enabled: true, only_allow_merge_if_build_succeeds: false, has_external_issue_tracker: false, repository_storage: "default", request_access_enabled: true, has_external_wiki: false, lfs_enabled: nil>, :namespace_id=>nil} missing required keys: [:namespace_id]
Shared Example Group: "issuable record that supports slash commands in its description and notes" called from ./spec/features/issues/user_uses_slash_commands_spec.rb:6
# ./app/models/project.rb:611:in `web_url'
# ./app/models/project.rb:975:in `hook_attrs'
# ./lib/gitlab/data_builder/note.rb:58:in `build_base_data'
# ./lib/gitlab/data_builder/note.rb:38:in `build'
# ./app/services/notes/post_process_service.rb:19:in `hook_data'
# ./app/services/notes/post_process_service.rb:23:in `execute_note_hooks'
# ./app/services/notes/post_process_service.rb:14:in `execute'
# ./app/workers/new_note_worker.rb:10:in `perform'
# ./app/services/notes/create_service.rb:29:in `execute'
# ./app/controllers/projects/notes_controller.rb:26:in `create'
# ./lib/gitlab/request_profiler/middleware.rb:15:in `call'
# ./lib/gitlab/middleware/go.rb:16:in `call'
# ./lib/gitlab/middleware/static.rb:9:in `call'
```
There were a number of issues:
1. 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.
2. Some outstanding Ajax requests (e.g. autocomplete) were still being loaded while `DatabaseCleaner` ran
3. `logout` did not always wait for logout actually to complete
Closes #21723
See merge request !6271
This commit is contained in:
commit
483a28a46b
|
|
@ -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!'
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
# 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) }
|
||||
let(:assignee) { create(:user, username: 'bob') }
|
||||
let(:guest) { create(:user) }
|
||||
|
|
@ -18,6 +21,11 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
login_with(master)
|
||||
end
|
||||
|
||||
after do
|
||||
# Ensure all outstanding Ajax requests are complete to avoid database deadlocks
|
||||
wait_for_ajax
|
||||
end
|
||||
|
||||
describe "new #{issuable_type}" do
|
||||
context 'with commands in the description' do
|
||||
it "creates the #{issuable_type} and interpret commands accordingly" do
|
||||
|
|
@ -44,10 +52,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
|
||||
context 'with a note containing commands' do
|
||||
it 'creates a note without the commands and interpret the commands accordingly' do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\""
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
|
||||
|
||||
expect(page).to have_content 'Awesome!'
|
||||
expect(page).not_to have_content '/assign @bob'
|
||||
|
|
@ -66,10 +71,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
|
||||
context 'with a note containing only commands' do
|
||||
it 'does not create a note but interpret the commands accordingly' do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/assign @bob\n/label ~bug\n/milestone %\"ASAP\""
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
|
||||
|
||||
expect(page).not_to have_content '/assign @bob'
|
||||
expect(page).not_to have_content '/label ~bug'
|
||||
|
|
@ -92,10 +94,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
|
||||
context "when current user can close #{issuable_type}" do
|
||||
it "closes the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/close"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/close")
|
||||
|
||||
expect(page).not_to have_content '/close'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -112,10 +111,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
end
|
||||
|
||||
it "does not close the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/close"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/close")
|
||||
|
||||
expect(page).not_to have_content '/close'
|
||||
expect(page).not_to have_content 'Your commands have been executed!'
|
||||
|
|
@ -133,10 +129,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
|
||||
context "when current user can reopen #{issuable_type}" do
|
||||
it "reopens the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/reopen"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/reopen")
|
||||
|
||||
expect(page).not_to have_content '/reopen'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -153,10 +146,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
end
|
||||
|
||||
it "does not reopen the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/reopen"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/reopen")
|
||||
|
||||
expect(page).not_to have_content '/reopen'
|
||||
expect(page).not_to have_content 'Your commands have been executed!'
|
||||
|
|
@ -169,10 +159,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
context "with a note changing the #{issuable_type}'s title" do
|
||||
context "when current user can change title of #{issuable_type}" do
|
||||
it "reopens the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/title Awesome new title"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/title Awesome new title")
|
||||
|
||||
expect(page).not_to have_content '/title'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -189,10 +176,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
end
|
||||
|
||||
it "does not reopen the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/title Awesome new title"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/title Awesome new title")
|
||||
|
||||
expect(page).not_to have_content '/title'
|
||||
expect(page).not_to have_content 'Your commands have been executed!'
|
||||
|
|
@ -204,10 +188,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
|
||||
context "with a note marking the #{issuable_type} as todo" do
|
||||
it "creates a new todo for the #{issuable_type}" do
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/todo"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/todo")
|
||||
|
||||
expect(page).not_to have_content '/todo'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -238,10 +219,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
expect(todo.author).to eq master
|
||||
expect(todo.user).to eq master
|
||||
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/done"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/done")
|
||||
|
||||
expect(page).not_to have_content '/done'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -254,10 +232,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
it "creates a new todo for the #{issuable_type}" do
|
||||
expect(issuable.subscribed?(master)).to be_falsy
|
||||
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/subscribe"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/subscribe")
|
||||
|
||||
expect(page).not_to have_content '/subscribe'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
@ -274,10 +249,7 @@ shared_examples 'issuable record that supports slash commands in its description
|
|||
it "creates a new todo for the #{issuable_type}" do
|
||||
expect(issuable.subscribed?(master)).to be_truthy
|
||||
|
||||
page.within('.js-main-target-form') do
|
||||
fill_in 'note[note]', with: "/unsubscribe"
|
||||
click_button 'Comment'
|
||||
end
|
||||
write_note("/unsubscribe")
|
||||
|
||||
expect(page).not_to have_content '/unsubscribe'
|
||||
expect(page).to have_content 'Your commands have been executed!'
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ module LoginHelpers
|
|||
def logout
|
||||
find(".header-user-dropdown-toggle").click
|
||||
click_link "Sign out"
|
||||
expect(page).to have_content('Signed out successfully')
|
||||
end
|
||||
|
||||
# Logout without JavaScript driver
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in New Issue