diff options
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/controllers/authorization_helpers.rb | 6 | ||||
-rw-r--r-- | spec/support/helpers/capybara_helpers.rb | 10 | ||||
-rw-r--r-- | spec/support/helpers/dropzone_helper.rb | 2 | ||||
-rw-r--r-- | spec/support/helpers/git_helpers.rb | 5 | ||||
-rw-r--r-- | spec/support/helpers/wiki_helpers.rb | 6 | ||||
-rw-r--r-- | spec/support/matchers/issuable_matchers.rb | 3 | ||||
-rw-r--r-- | spec/support/shared_examples/requests/api/discussions.rb | 23 | ||||
-rw-r--r-- | spec/support/shared_examples/wiki_file_attachments_examples.rb | 8 |
8 files changed, 29 insertions, 34 deletions
diff --git a/spec/support/controllers/authorization_helpers.rb b/spec/support/controllers/authorization_helpers.rb deleted file mode 100644 index e1786e0ca8a..00000000000 --- a/spec/support/controllers/authorization_helpers.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -def forbid_controller_ability!(ability) - allow(controller).to receive(:can?).and_call_original - allow(controller).to receive(:can?).with(anything, ability, any_args).and_return(false) -end diff --git a/spec/support/helpers/capybara_helpers.rb b/spec/support/helpers/capybara_helpers.rb index 13ec179b734..a7baa7042c9 100644 --- a/spec/support/helpers/capybara_helpers.rb +++ b/spec/support/helpers/capybara_helpers.rb @@ -46,14 +46,4 @@ module CapybaraHelpers def javascript_test? Capybara.current_driver == Capybara.javascript_driver end - - def scroll_to(element) - raise 'JS not available' unless javascript_test? - - script = <<-JS - arguments[0].scrollIntoView(true); - JS - - page.driver.browser.execute_script(script, element.native) - end end diff --git a/spec/support/helpers/dropzone_helper.rb b/spec/support/helpers/dropzone_helper.rb index 3f37673dadd..a0f261b312e 100644 --- a/spec/support/helpers/dropzone_helper.rb +++ b/spec/support/helpers/dropzone_helper.rb @@ -14,8 +14,6 @@ module DropzoneHelper # If it's 'false', then the helper will NOT wait for backend response # It lets to test behaviors while AJAX is processing. def dropzone_file(files, max_file_size = 0, wait_for_queuecomplete = true) - # Assert that there is a dropzone to use (waiting until it is ready) - expect(page).to have_css('.div-dropzone') # Generate a fake file input that Capybara can attach to page.execute_script <<-JS.strip_heredoc $('#fakeFileInput').remove(); diff --git a/spec/support/helpers/git_helpers.rb b/spec/support/helpers/git_helpers.rb index 05e31a1154a..99c5871ba54 100644 --- a/spec/support/helpers/git_helpers.rb +++ b/spec/support/helpers/git_helpers.rb @@ -2,11 +2,8 @@ module GitHelpers def rugged_repo(repository) - rugged_repo_at_path(repository.disk_path + '.git') - end + path = File.join(TestEnv.repos_path, repository.disk_path + '.git') - def rugged_repo_at_path(relative_path) - path = File.join(TestEnv.repos_path, relative_path) Rugged::Repository.new(path) end end diff --git a/spec/support/helpers/wiki_helpers.rb b/spec/support/helpers/wiki_helpers.rb index 0cf70fd4ef7..06cea728b42 100644 --- a/spec/support/helpers/wiki_helpers.rb +++ b/spec/support/helpers/wiki_helpers.rb @@ -12,10 +12,4 @@ module WikiHelpers ::Wikis::CreateAttachmentService.new(project, user, opts) .execute[:result][:file_path] end - - # Generate the form field name for a given attribute of an object. - # This is rather general, but is currently only used in the wiki featur tests. - def form_field_name(obj, attr_name) - "#{ActiveModel::Naming.param_key(obj)}[#{attr_name}]" - end end diff --git a/spec/support/matchers/issuable_matchers.rb b/spec/support/matchers/issuable_matchers.rb index ab15a80bf60..743f0b8c932 100644 --- a/spec/support/matchers/issuable_matchers.rb +++ b/spec/support/matchers/issuable_matchers.rb @@ -2,8 +2,7 @@ RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".md"| match do |actual| - # anchors may be invisible - node = find("#{parent} h#{level} a#user-content-#{id}", visible: false) + node = find("#{parent} h#{level} a#user-content-#{id}") expect(node[:href]).to end_with("##{id}") diff --git a/spec/support/shared_examples/requests/api/discussions.rb b/spec/support/shared_examples/requests/api/discussions.rb index a36bc2dc9b5..2a5a48f3054 100644 --- a/spec/support/shared_examples/requests/api/discussions.rb +++ b/spec/support/shared_examples/requests/api/discussions.rb @@ -117,6 +117,29 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r expect(response).to have_gitlab_http_status(401) end + it 'tracks a Notes::CreateService event' do + expect(Gitlab::Tracking).to receive(:event) do |category, action, data| + expect(category).to eq('Notes::CreateService') + expect(action).to eq('execute') + expect(data[:label]).to eq('note') + expect(data[:value]).to be_an(Integer) + end + + post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!' } + end + + context 'with notes_create_service_tracking feature flag disabled' do + before do + stub_feature_flags(notes_create_service_tracking: false) + end + + it 'does not track any events' do + expect(Gitlab::Tracking).not_to receive(:event) + + post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: { body: 'hi!' } + end + end + context 'when an admin or owner makes the request' do it 'accepts the creation date to be set' do creation_time = 2.weeks.ago diff --git a/spec/support/shared_examples/wiki_file_attachments_examples.rb b/spec/support/shared_examples/wiki_file_attachments_examples.rb index a43b7c0300f..22fbfb48928 100644 --- a/spec/support/shared_examples/wiki_file_attachments_examples.rb +++ b/spec/support/shared_examples/wiki_file_attachments_examples.rb @@ -42,7 +42,7 @@ shared_examples 'wiki file attachments' do end end - context 'uploading is complete' do + context 'uploading is complete', :quarantine do it 'shows "Attach a file" button on uploading complete' do attach_with_dropzone wait_for_requests @@ -52,11 +52,11 @@ shared_examples 'wiki file attachments' do end it 'the markdown link is added to the page' do - fill_in(:wiki_page_content, with: '') + fill_in(:wiki_content, with: '') attach_with_dropzone(true) wait_for_requests - expect(page.find('#wiki_page_content').value) + expect(page.find('#wiki_content').value) .to match(%r{\!\[dk\]\(uploads/\h{32}/dk\.png\)$}) end @@ -70,7 +70,7 @@ shared_examples 'wiki file attachments' do img_link = page.find('a.no-attachment-icon img')['src'] expect(link).to eq img_link - expect(URI.parse(link).path).to eq File.join(wiki.wiki_page_path, file_path) + expect(URI.parse(link).path).to eq File.join(wiki.wiki_base_path, file_path) end it 'the file has been added to the wiki repository' do |