diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:08:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-24 18:08:44 +0300 |
commit | 120f4aaedc8fe830a3f572491d240d8ee6addefb (patch) | |
tree | a2138baa55dfa67d292fb1a83ce686ee7f5d10a5 /spec | |
parent | 729e3765d5feb762df1ccfbc228a8dd4662aa3f9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/application_settings.rb | 1 | ||||
-rw-r--r-- | spec/features/admin/admin_settings_spec.rb | 25 | ||||
-rw-r--r-- | spec/features/broadcast_messages_spec.rb | 12 | ||||
-rw-r--r-- | spec/features/projects/clusters/gcp_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/snippets/components/show_spec.js (renamed from spec/frontend/snippets/components/app_spec.js) | 2 | ||||
-rw-r--r-- | spec/helpers/user_callouts_helper_spec.rb | 20 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/concerns/optionally_search_spec.rb | 30 | ||||
-rw-r--r-- | spec/models/project_services/discord_service_spec.rb | 18 | ||||
-rw-r--r-- | spec/views/admin/application_settings/general.html.haml_spec.rb (renamed from spec/views/admin/application_settings/integrations.html.haml_spec.rb) | 4 |
10 files changed, 108 insertions, 18 deletions
diff --git a/spec/factories/application_settings.rb b/spec/factories/application_settings.rb index d4571b9861d..8ac003d0a98 100644 --- a/spec/factories/application_settings.rb +++ b/spec/factories/application_settings.rb @@ -3,5 +3,6 @@ FactoryBot.define do factory :application_setting do default_projects_limit { 42 } + import_sources { [] } end end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 9b275a8897b..743aa0ed60e 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -194,12 +194,6 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc expect(page).to have_content "Application settings saved successfully" expect(current_settings.terminal_max_session_time).to eq(15) end - end - - context 'Integrations page' do - before do - visit integrations_admin_application_settings_path - end it 'Enable hiding third party offers' do page.within('.as-third-party-offers') do @@ -241,6 +235,25 @@ describe 'Admin updates settings', :clean_gitlab_redis_shared_state, :do_not_moc end end + context 'Integration page', :js do + before do + visit integrations_admin_application_settings_path + end + + it 'allows user to dismiss deprecation notice' do + expect(page).to have_content('Some settings have moved') + + click_button 'Dismiss' + wait_for_requests + + expect(page).not_to have_content('Some settings have moved') + + visit integrations_admin_application_settings_path + + expect(page).not_to have_content('Some settings have moved') + end + end + context 'CI/CD page' do it 'Change CI/CD settings' do visit ci_cd_admin_application_settings_path diff --git a/spec/features/broadcast_messages_spec.rb b/spec/features/broadcast_messages_spec.rb index 809e53ed7f7..41e8e969610 100644 --- a/spec/features/broadcast_messages_spec.rb +++ b/spec/features/broadcast_messages_spec.rb @@ -68,4 +68,16 @@ describe 'Broadcast Messages' do expect(page).to have_content "Hi #{user.name}" end + + it 'renders broadcast message with placeholders and styled links' do + create(:broadcast_message, broadcast_type: 'notification', message: "Hi {{name}} <a href='gitlab.com' style='color: purple'>click</a>") + + user = create(:user) + sign_in(user) + + visit root_path + + expected_html = "<p>Hi #{user.name} <a href=\"gitlab.com\" style=\"color: purple\">click</a></p>" + expect(page.body).to include(expected_html) + end end diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb index df786cf0818..15045023cf8 100644 --- a/spec/features/projects/clusters/gcp_spec.rb +++ b/spec/features/projects/clusters/gcp_spec.rb @@ -208,7 +208,7 @@ describe 'Gcp Cluster', :js, :do_not_mock_admin_mode do stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') sign_in(admin) gitlab_enable_admin_mode_sign_in(admin) - visit integrations_admin_application_settings_path + visit general_admin_application_settings_path end it 'user does not see the offer' do diff --git a/spec/frontend/snippets/components/app_spec.js b/spec/frontend/snippets/components/show_spec.js index a683ed9aaba..33608df8cf2 100644 --- a/spec/frontend/snippets/components/app_spec.js +++ b/spec/frontend/snippets/components/show_spec.js @@ -1,4 +1,4 @@ -import SnippetApp from '~/snippets/components/app.vue'; +import SnippetApp from '~/snippets/components/show.vue'; import SnippetHeader from '~/snippets/components/snippet_header.vue'; import SnippetTitle from '~/snippets/components/snippet_title.vue'; import SnippetBlob from '~/snippets/components/snippet_blob_view.vue'; diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb index 547bf693e94..b123b11d278 100644 --- a/spec/helpers/user_callouts_helper_spec.rb +++ b/spec/helpers/user_callouts_helper_spec.rb @@ -47,6 +47,26 @@ describe UserCalloutsHelper do end end + describe '.show_admin_integrations_moved?' do + subject { helper.show_admin_integrations_moved? } + + context 'when user has not dismissed' do + before do + allow(helper).to receive(:user_dismissed?).with(described_class::ADMIN_INTEGRATIONS_MOVED) { false } + end + + it { is_expected.to be true } + end + + context 'when user dismissed' do + before do + allow(helper).to receive(:user_dismissed?).with(described_class::ADMIN_INTEGRATIONS_MOVED) { true } + end + + it { is_expected.to be false } + end + end + describe '.render_flash_user_callout' do it 'renders the flash_user_callout partial' do expect(helper).to receive(:render) diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb index f2a0b93ef28..9a2cf014007 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb @@ -67,6 +67,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do expect(step.break?).to be false end + + it 'logs the authorization' do + expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline authorized', project_id: project.id, user_id: user.id) + + perform! + end end context 'when validation return false' do @@ -86,6 +92,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do expect(step.break?).to be true end + + it 'logs the authorization' do + expect(Gitlab::AppLogger).to receive(:info).with(message: 'Pipeline not authorized', project_id: project.id, user_id: user.id) + + perform! + end end end diff --git a/spec/models/concerns/optionally_search_spec.rb b/spec/models/concerns/optionally_search_spec.rb index 71cf536db89..e1eb4cf8cd2 100644 --- a/spec/models/concerns/optionally_search_spec.rb +++ b/spec/models/concerns/optionally_search_spec.rb @@ -3,28 +3,39 @@ require 'spec_helper' describe OptionallySearch do - let(:model) do - Class.new(ActiveRecord::Base) do - self.table_name = 'users' - - include OptionallySearch + describe '.search' do + let(:model) do + Class.new do + include OptionallySearch + end end - end - describe '.search' do it 'raises NotImplementedError' do expect { model.search('foo') }.to raise_error(NotImplementedError) end end describe '.optionally_search' do + let(:model) do + Class.new(ActiveRecord::Base) do + self.table_name = 'users' + + include OptionallySearch + + def self.search(query, **options) + [query, options] + end + end + end + context 'when a query is given' do it 'delegates to the search method' do expect(model) .to receive(:search) .with('foo', {}) + .and_call_original - model.optionally_search('foo') + expect(model.optionally_search('foo')).to eq(['foo', {}]) end end @@ -33,8 +44,9 @@ describe OptionallySearch do expect(model) .to receive(:search) .with('foo', some_option: true) + .and_call_original - model.optionally_search('foo', some_option: true) + expect(model.optionally_search('foo', some_option: true)).to eq(['foo', { some_option: true }]) end end diff --git a/spec/models/project_services/discord_service_spec.rb b/spec/models/project_services/discord_service_spec.rb index 96ac532dcd1..b5a54676dd7 100644 --- a/spec/models/project_services/discord_service_spec.rb +++ b/spec/models/project_services/discord_service_spec.rb @@ -31,6 +31,24 @@ describe DiscordService do WebMock.stub_request(:post, webhook_url) end + it 'uses the right embed parameters' do + builder = Discordrb::Webhooks::Builder.new + + allow_next_instance_of(Discordrb::Webhooks::Client) do |client| + allow(client).to receive(:execute).and_yield(builder) + end + + subject.execute(sample_data) + + expect(builder.to_json_hash[:embeds].first).to include( + description: start_with("#{user.name} pushed to branch [master](http://localhost/#{project.namespace.path}/#{project.path}/commits/master) of"), + author: hash_including( + icon_url: start_with('https://www.gravatar.com/avatar/'), + name: user.name + ) + ) + end + context 'DNS rebind to local address' do before do stub_dns(webhook_url, ip_address: '192.168.2.120') diff --git a/spec/views/admin/application_settings/integrations.html.haml_spec.rb b/spec/views/admin/application_settings/general.html.haml_spec.rb index 392d43ef2d4..e6a0307afd9 100644 --- a/spec/views/admin/application_settings/integrations.html.haml_spec.rb +++ b/spec/views/admin/application_settings/general.html.haml_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' -describe 'admin/application_settings/integrations.html.haml' do +describe 'admin/application_settings/general.html.haml' do let(:app_settings) { build(:application_setting) } + let(:user) { create(:admin) } describe 'sourcegraph integration' do let(:sourcegraph_flag) { true } @@ -11,6 +12,7 @@ describe 'admin/application_settings/integrations.html.haml' do before do assign(:application_setting, app_settings) allow(Gitlab::Sourcegraph).to receive(:feature_available?).and_return(sourcegraph_flag) + allow(view).to receive(:current_user).and_return(user) end context 'when sourcegraph feature is enabled' do |