summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_eks.html.haml_spec.rb4
-rw-r--r--spec/views/admin/application_settings/repository.html.haml_spec.rb5
-rw-r--r--spec/views/admin/broadcast_messages/index.html.haml_spec.rb36
-rw-r--r--spec/views/devise/sessions/new.html.haml_spec.rb2
-rw-r--r--spec/views/devise/shared/_signup_box.html.haml_spec.rb6
-rw-r--r--spec/views/groups/group_members/index.html.haml_spec.rb42
-rw-r--r--spec/views/layouts/_header_search.html.haml_spec.rb113
-rw-r--r--spec/views/layouts/_published_experiments.html.haml_spec.rb32
-rw-r--r--spec/views/projects/commits/_commit.html.haml_spec.rb6
-rw-r--r--spec/views/projects/empty.html.haml_spec.rb15
-rw-r--r--spec/views/projects/project_members/index.html.haml_spec.rb33
-rw-r--r--spec/views/projects/runners/_specific_runners.html.haml_spec.rb4
-rw-r--r--spec/views/projects/tags/index.html.haml_spec.rb6
-rw-r--r--spec/views/search/_results.html.haml_spec.rb39
-rw-r--r--spec/views/shared/_gl_toggle.haml_spec.rb85
-rw-r--r--spec/views/shared/_global_alert.html.haml_spec.rb29
-rw-r--r--spec/views/shared/issuable/_sidebar.html.haml_spec.rb31
-rw-r--r--spec/views/shared/wikis/_sidebar.html.haml_spec.rb2
18 files changed, 270 insertions, 220 deletions
diff --git a/spec/views/admin/application_settings/_eks.html.haml_spec.rb b/spec/views/admin/application_settings/_eks.html.haml_spec.rb
index e407970c7a4..d16cbc7b299 100644
--- a/spec/views/admin/application_settings/_eks.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_eks.html.haml_spec.rb
@@ -16,8 +16,8 @@ RSpec.describe 'admin/application_settings/_eks' do
shared_examples 'EKS secret access key input' do
it 'renders an empty password field' do
render
- expect(rendered).to have_field('Secret access key', type: 'password')
- expect(page.find_field('Secret access key').value).to be_blank
+ expect(rendered).to have_field('AWS secret access key (Optional)', type: 'password')
+ expect(page.find_field('AWS secret access key (Optional)').value).to be_blank
end
end
diff --git a/spec/views/admin/application_settings/repository.html.haml_spec.rb b/spec/views/admin/application_settings/repository.html.haml_spec.rb
index 30047878b0f..e28a69d0f87 100644
--- a/spec/views/admin/application_settings/repository.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/repository.html.haml_spec.rb
@@ -21,8 +21,9 @@ RSpec.describe 'admin/application_settings/repository.html.haml' do
it 'renders the correct setting section content' do
render
- expect(rendered).to have_content("Default initial branch name")
- expect(rendered).to have_content("The default name for the initial branch of new repositories created in the instance.")
+ expect(rendered).to have_content("Initial default branch name")
+ expect(rendered).to have_content("Set the initial name and protections for the default branch of new repositories created in the instance.")
+ expect(rendered).to have_content("Initial default branch protection")
end
end
end
diff --git a/spec/views/admin/broadcast_messages/index.html.haml_spec.rb b/spec/views/admin/broadcast_messages/index.html.haml_spec.rb
new file mode 100644
index 00000000000..e1dc76428df
--- /dev/null
+++ b/spec/views/admin/broadcast_messages/index.html.haml_spec.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'admin/broadcast_messages/index' do
+ describe 'Target roles select and table column' do
+ let(:feature_flag_state) { true }
+
+ let_it_be(:message) { create(:broadcast_message, broadcast_type: 'banner', target_access_levels: [Gitlab::Access::GUEST, Gitlab::Access::DEVELOPER]) }
+
+ before do
+ assign(:broadcast_messages, BroadcastMessage.page(1))
+ assign(:broadcast_message, BroadcastMessage.new)
+
+ stub_feature_flags(role_targeted_broadcast_messages: feature_flag_state)
+
+ render
+ end
+
+ it 'rendered' do
+ expect(rendered).to have_content('Target roles')
+ expect(rendered).to have_content('Owner')
+ expect(rendered).to have_content('Guest, Developer')
+ end
+
+ context 'when feature flag is off' do
+ let(:feature_flag_state) { false }
+
+ it 'is not rendered' do
+ expect(rendered).not_to have_content('Target roles')
+ expect(rendered).not_to have_content('Owner')
+ expect(rendered).not_to have_content('Guest, Developer')
+ end
+ end
+ end
+end
diff --git a/spec/views/devise/sessions/new.html.haml_spec.rb b/spec/views/devise/sessions/new.html.haml_spec.rb
index 0109d05abe4..e8232a2c067 100644
--- a/spec/views/devise/sessions/new.html.haml_spec.rb
+++ b/spec/views/devise/sessions/new.html.haml_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe 'devise/sessions/new' do
before do
stub_devise
disable_captcha
- allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ allow(Gitlab).to receive(:com?).and_return(true)
end
it 'when flash is anything it renders marketing text' do
diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb
index 37dbfd39f2d..1f0cd213f7b 100644
--- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb
+++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe 'devise/shared/_signup_box' do
context 'when on .com' do
before do
- allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ allow(Gitlab).to receive(:com?).and_return(true)
end
it 'shows expected GitLab text' do
@@ -39,7 +39,7 @@ RSpec.describe 'devise/shared/_signup_box' do
context 'when not on .com' do
before do
- allow(Gitlab).to receive(:dev_env_or_com?).and_return(false)
+ allow(Gitlab).to receive(:com?).and_return(false)
end
it 'shows expected text without GitLab' do
@@ -53,7 +53,7 @@ RSpec.describe 'devise/shared/_signup_box' do
context 'when terms are not enforced' do
before do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enforce_terms?).and_return(false)
- allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ allow(Gitlab).to receive(:com?).and_return(true)
end
it 'shows expected text with placeholders' do
diff --git a/spec/views/groups/group_members/index.html.haml_spec.rb b/spec/views/groups/group_members/index.html.haml_spec.rb
index 8e190c24495..40d4c9d33c9 100644
--- a/spec/views/groups/group_members/index.html.haml_spec.rb
+++ b/spec/views/groups/group_members/index.html.haml_spec.rb
@@ -10,7 +10,6 @@ RSpec.describe 'groups/group_members/index', :aggregate_failures do
allow(view).to receive(:group_members_app_data).and_return({})
allow(view).to receive(:current_user).and_return(user)
assign(:group, group)
- assign(:group_member, build(:group_member, group: group))
end
context 'when user can invite members for the group' do
@@ -18,42 +17,15 @@ RSpec.describe 'groups/group_members/index', :aggregate_failures do
group.add_owner(user)
end
- context 'when modal is enabled' do
- it 'renders as expected' do
- render
-
- expect(rendered).to have_content('Group members')
- expect(rendered).to have_content('You can invite a new member')
-
- expect(rendered).to have_selector('.js-invite-group-trigger')
- expect(rendered).to have_selector('.js-invite-members-trigger')
- expect(response).to render_template(partial: 'groups/_invite_members_modal')
-
- expect(rendered).not_to have_selector('#invite-member-tab')
- expect(rendered).not_to have_selector('#invite-group-tab')
- expect(response).not_to render_template(partial: 'shared/members/_invite_group')
- end
- end
-
- context 'when modal is not enabled' do
- before do
- stub_feature_flags(invite_members_group_modal: false)
- end
-
- it 'renders as expected' do
- render
-
- expect(rendered).to have_content('Group members')
- expect(rendered).to have_content('You can invite a new member')
+ it 'renders as expected' do
+ render
- expect(rendered).to have_selector('#invite-member-tab')
- expect(rendered).to have_selector('#invite-group-tab')
- expect(response).to render_template(partial: 'shared/members/_invite_group')
+ expect(rendered).to have_content('Group members')
+ expect(rendered).to have_content('You can invite a new member')
- expect(rendered).not_to have_selector('.js-invite-group-trigger')
- expect(rendered).not_to have_selector('.js-invite-members-trigger')
- expect(response).not_to render_template(partial: 'groups/_invite_members_modal')
- end
+ expect(rendered).to have_selector('.js-invite-group-trigger')
+ expect(rendered).to have_selector('.js-invite-members-trigger')
+ expect(response).to render_template(partial: 'groups/_invite_members_modal')
end
end
diff --git a/spec/views/layouts/_header_search.html.haml_spec.rb b/spec/views/layouts/_header_search.html.haml_spec.rb
new file mode 100644
index 00000000000..3ab4ae6a483
--- /dev/null
+++ b/spec/views/layouts/_header_search.html.haml_spec.rb
@@ -0,0 +1,113 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'layouts/_header_search' do
+ let(:project) { nil }
+ let(:group) { nil }
+ let(:scope) { nil }
+ let(:ref) { nil }
+ let(:code_search) { false }
+ let(:for_snippets) { false}
+
+ let(:header_search_context) do
+ {
+ project: project,
+ group: group,
+ scope: scope,
+ ref: ref,
+ code_search: code_search,
+ for_snippets: for_snippets
+ }
+ end
+
+ before do
+ allow(view).to receive(:header_search_context).and_return(header_search_context)
+ end
+
+ shared_examples 'hidden fields are properly set' do
+ context 'when search_context has a scope value' do
+ let(:scope) { 'issues' }
+
+ it 'sets scope input to issues' do
+ render
+
+ expect(rendered).to have_css("input[name='scope'][value='#{scope}']", count: 1, visible: false)
+ end
+ end
+
+ context 'when search_context has a code_search value' do
+ let(:code_search) { true }
+
+ it 'sets search_code input to true' do
+ render
+
+ expect(rendered).to have_css("input[name='search_code'][value='#{code_search}']", count: 1, visible: false)
+ end
+ end
+
+ context 'when search_context has a ref value' do
+ let(:ref) { 'test-branch' }
+
+ it 'sets repository_ref input to test-branch' do
+ render
+
+ expect(rendered).to have_css("input[name='repository_ref'][value='#{ref}']", count: 1, visible: false)
+ end
+ end
+
+ context 'when search_context has a for_snippets value' do
+ let(:for_snippets) { true }
+
+ it 'sets for_snippets input to true' do
+ render
+
+ expect(rendered).to have_css("input[name='snippets'][value='#{for_snippets}']", count: 1, visible: false)
+ end
+ end
+
+ context 'nav_source' do
+ it 'always set to navbar' do
+ render
+
+ expect(rendered).to have_css("input[name='nav_source'][value='navbar']", count: 1, visible: false)
+ end
+ end
+
+ context 'submit button' do
+ it 'always renders for specs' do
+ render
+
+ expect(rendered).to have_css('noscript button', text: 'Search')
+ end
+ end
+ end
+
+ context 'when doing a project level search' do
+ let(:project) do
+ { id: 123, name: 'foo' }
+ end
+
+ it 'sets project_id field' do
+ render
+
+ expect(rendered).to have_css("input[name='project_id'][value='#{project[:id]}']", count: 1, visible: false)
+ end
+
+ it_behaves_like 'hidden fields are properly set'
+ end
+
+ context 'when doing a group level search' do
+ let(:group) do
+ { id: 123, name: 'bar' }
+ end
+
+ it 'sets group_id field' do
+ render
+
+ expect(rendered).to have_css("input[name='group_id'][value='#{group[:id]}']", count: 1, visible: false)
+ end
+
+ it_behaves_like 'hidden fields are properly set'
+ end
+end
diff --git a/spec/views/layouts/_published_experiments.html.haml_spec.rb b/spec/views/layouts/_published_experiments.html.haml_spec.rb
index d1ade8ddd6e..84894554bd9 100644
--- a/spec/views/layouts/_published_experiments.html.haml_spec.rb
+++ b/spec/views/layouts/_published_experiments.html.haml_spec.rb
@@ -4,22 +4,20 @@ require 'spec_helper'
RSpec.describe 'layouts/_published_experiments', :experiment do
before do
- stub_const('TestControlExperiment', ApplicationExperiment)
- stub_const('TestCandidateExperiment', ApplicationExperiment)
- stub_const('TestExcludedExperiment', ApplicationExperiment)
+ # Stub each experiment to be enabled, otherwise tracking does not happen.
+ stub_experiments(
+ test_control: :control,
+ test_excluded: true,
+ test_published_only: :control,
+ test_candidate: :candidate,
+ test_variant: :variant_name
+ )
- TestControlExperiment.new('test_control').tap do |e|
- e.variant(:control)
- e.publish
- end
- TestCandidateExperiment.new('test_candidate').tap do |e|
- e.variant(:candidate)
- e.publish
- end
- TestExcludedExperiment.new('test_excluded').tap do |e|
- e.exclude!
- e.publish
- end
+ experiment(:test_control) { }
+ experiment(:test_excluded) { |e| e.exclude! }
+ experiment(:test_candidate) { |e| e.candidate { } }
+ experiment(:test_variant) { |e| e.variant(:variant_name) { } }
+ experiment(:test_published_only).publish
render
end
@@ -29,7 +27,9 @@ RSpec.describe 'layouts/_published_experiments', :experiment do
expect(output).to include('gl.experiments = {')
expect(output).to match(/"test_control":\{[^}]*"variant":"control"/)
- expect(output).to match(/"test_candidate":\{[^}]*"variant":"candidate"/)
expect(output).not_to include('"test_excluded"')
+ expect(output).to match(/"test_candidate":\{[^}]*"variant":"candidate"/)
+ expect(output).to match(/"test_variant":\{[^}]*"variant":"variant_name"/)
+ expect(output).to match(/"test_published_only":\{[^}]*"variant":"control"/)
end
end
diff --git a/spec/views/projects/commits/_commit.html.haml_spec.rb b/spec/views/projects/commits/_commit.html.haml_spec.rb
index 5c66fbe7dd7..da93871e0e4 100644
--- a/spec/views/projects/commits/_commit.html.haml_spec.rb
+++ b/spec/views/projects/commits/_commit.html.haml_spec.rb
@@ -33,7 +33,7 @@ RSpec.describe 'projects/commits/_commit.html.haml' do
let(:ref) { GpgHelpers::SIGNED_COMMIT_SHA }
it 'does not display a loading spinner for GPG status' do
- render partial: template, locals: {
+ render partial: template, formats: :html, locals: {
project: project,
ref: ref,
commit: commit
@@ -69,7 +69,7 @@ RSpec.describe 'projects/commits/_commit.html.haml' do
end
it 'does not display a ci status icon' do
- render partial: template, locals: {
+ render partial: template, formats: :html, locals: {
project: project,
ref: ref,
commit: commit
@@ -85,7 +85,7 @@ RSpec.describe 'projects/commits/_commit.html.haml' do
end
it 'does display a ci status icon when pipelines are enabled' do
- render partial: template, locals: {
+ render partial: template, formats: :html, locals: {
project: project,
ref: ref,
commit: commit
diff --git a/spec/views/projects/empty.html.haml_spec.rb b/spec/views/projects/empty.html.haml_spec.rb
index 416dfc10174..6077dda3c98 100644
--- a/spec/views/projects/empty.html.haml_spec.rb
+++ b/spec/views/projects/empty.html.haml_spec.rb
@@ -25,6 +25,21 @@ RSpec.describe 'projects/empty' do
expect(rendered).to have_content("git clone")
end
+
+ context 'when default branch name contains special shell characters' do
+ let(:branch_name) { ';rm -rf /' }
+
+ before do
+ allow(project).to receive(:default_branch_or_main).and_return(branch_name)
+ end
+
+ it 'escapes the default branch name' do
+ render
+
+ expect(rendered).not_to have_content(branch_name)
+ expect(rendered).to have_content(branch_name.shellescape)
+ end
+ end
end
context 'when user can not push code on the project' do
diff --git a/spec/views/projects/project_members/index.html.haml_spec.rb b/spec/views/projects/project_members/index.html.haml_spec.rb
index b9b0d57bcb5..7186a5f1766 100644
--- a/spec/views/projects/project_members/index.html.haml_spec.rb
+++ b/spec/views/projects/project_members/index.html.haml_spec.rb
@@ -11,7 +11,6 @@ RSpec.describe 'projects/project_members/index', :aggregate_failures do
allow(view).to receive(:project_members_app_data_json).and_return({})
allow(view).to receive(:current_user).and_return(user)
assign(:project, project)
- assign(:project_member, build(:project_member, project: source))
end
context 'when user can invite members for the project' do
@@ -44,38 +43,6 @@ RSpec.describe 'projects/project_members/index', :aggregate_failures do
end
end
end
-
- context 'when modal is not enabled' do
- before do
- stub_feature_flags(invite_members_group_modal: false)
- end
-
- it 'renders as expected' do
- render
-
- expect(rendered).to have_content('Project members')
- expect(rendered).to have_content('You can invite a new member')
- expect(rendered).not_to have_selector('.js-invite-group-trigger')
- expect(rendered).not_to have_selector('.js-invite-members-trigger')
- expect(rendered).not_to have_content('Members can be added by project')
- expect(response).not_to render_template(partial: 'projects/_invite_members_modal')
- expect(response).to render_template(partial: 'shared/members/_invite_member')
- end
-
- context 'when project can not be shared' do
- before do
- project.namespace.share_with_group_lock = true
- end
-
- it 'renders as expected' do
- render
-
- expect(rendered).to have_content('Project members')
- expect(rendered).to have_content('You can invite a new member')
- expect(response).not_to render_template(partial: 'projects/_invite_members_modal')
- end
- end
- end
end
context 'when user can not invite members or group for the project' do
diff --git a/spec/views/projects/runners/_specific_runners.html.haml_spec.rb b/spec/views/projects/runners/_specific_runners.html.haml_spec.rb
index ace3502dd1e..ce16e0d5ac6 100644
--- a/spec/views/projects/runners/_specific_runners.html.haml_spec.rb
+++ b/spec/views/projects/runners/_specific_runners.html.haml_spec.rb
@@ -11,12 +11,14 @@ RSpec.describe 'projects/runners/specific_runners.html.haml' do
@project = project
@assignable_runners = []
@project_runners = []
+ allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:reset_registration_token_namespace_project_settings_ci_cd_path).and_return('banana_url')
end
context 'when project runner registration is allowed' do
before do
stub_application_setting(valid_runner_registrars: ['project'])
+ allow(view).to receive(:can?).with(user, :register_project_runners, project).and_return(true)
end
it 'enables the Remove project button for a project' do
@@ -32,7 +34,7 @@ RSpec.describe 'projects/runners/specific_runners.html.haml' do
stub_application_setting(valid_runner_registrars: ['group'])
end
- it 'does not enable the the Remove project button for a project' do
+ it 'does not enable the Remove project button for a project' do
render 'projects/runners/specific_runners', project: project
expect(rendered).to have_content 'Please contact an admin to register runners.'
diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb
index ebd526284d1..ae59c1aa4b2 100644
--- a/spec/views/projects/tags/index.html.haml_spec.rb
+++ b/spec/views/projects/tags/index.html.haml_spec.rb
@@ -6,7 +6,11 @@ RSpec.describe 'projects/tags/index.html.haml' do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:tags) { project.repository.tags }
let_it_be(:git_tag) { project.repository.tags.last }
- let_it_be(:release) { create(:release, project: project, sha: git_tag.target_commit.sha) }
+ let_it_be(:release) do
+ create(:release, project: project,
+ sha: git_tag.target_commit.sha,
+ tag: 'v1.1.0')
+ end
let(:pipeline) { create(:ci_pipeline, :success, project: project, ref: git_tag.name, sha: release.sha) }
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index dcf1f46b46c..72e2d7131c0 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -58,17 +58,17 @@ RSpec.describe 'search/_results' do
context 'rendering all types of search results' do
let_it_be(:project) { create(:project, :repository, :wiki_repo) }
- let_it_be(:issue) { create(:issue, project: project, title: '*') }
- let_it_be(:merge_request) { create(:merge_request, title: '*', source_project: project, target_project: project) }
- let_it_be(:milestone) { create(:milestone, title: '*', project: project) }
- let_it_be(:note) { create(:discussion_note_on_issue, project: project, note: '*') }
- let_it_be(:wiki_blob) { create(:wiki_page, wiki: project.wiki, content: '*') }
+ let_it_be(:issue) { create(:issue, project: project, title: 'testing') }
+ let_it_be(:merge_request) { create(:merge_request, title: 'testing', source_project: project, target_project: project) }
+ let_it_be(:milestone) { create(:milestone, title: 'testing', project: project) }
+ let_it_be(:note) { create(:discussion_note_on_issue, project: project, note: 'testing') }
+ let_it_be(:wiki_blob) { create(:wiki_page, wiki: project.wiki, content: 'testing') }
let_it_be(:user) { create(:admin) }
%w[issues merge_requests].each do |search_scope|
context "when scope is #{search_scope}" do
let(:scope) { search_scope }
- let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
+ let(:search_objects) { Gitlab::ProjectSearchResults.new(user, 'testing', project: project).objects(scope) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'renders the click text event tracking attributes' do
@@ -96,10 +96,35 @@ RSpec.describe 'search/_results' do
end
end
+ describe 'git blame click tracking' do
+ let(:scope) { 'blobs' }
+ let(:search_objects) { Gitlab::ProjectSearchResults.new(user, 'testing', project: project).objects(scope) }
+
+ context 'when admin mode is enabled', :enable_admin_mode do
+ it 'renders the click link event tracking attributes' do
+ render
+
+ expect(rendered).to have_selector('[data-track-action=click_link]')
+ expect(rendered).to have_selector('[data-track-label=git_blame]')
+ expect(rendered).to have_selector('[data-track-property=search_result]')
+ end
+ end
+
+ context 'when admin mode is disabled' do
+ it 'does not render the click link event tracking attributes' do
+ render
+
+ expect(rendered).not_to have_selector('[data-track-action=click_link]')
+ expect(rendered).not_to have_selector('[data-track-label=git_blame]')
+ expect(rendered).not_to have_selector('[data-track-property=search_result]')
+ end
+ end
+ end
+
%w[blobs notes wiki_blobs milestones].each do |search_scope|
context "when scope is #{search_scope}" do
let(:scope) { search_scope }
- let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
+ let(:search_objects) { Gitlab::ProjectSearchResults.new(user, 'testing', project: project).objects(scope) }
context 'when admin mode is enabled', :enable_admin_mode do
it 'renders the click text event tracking attributes' do
diff --git a/spec/views/shared/_gl_toggle.haml_spec.rb b/spec/views/shared/_gl_toggle.haml_spec.rb
deleted file mode 100644
index 3ac1ef30c84..00000000000
--- a/spec/views/shared/_gl_toggle.haml_spec.rb
+++ /dev/null
@@ -1,85 +0,0 @@
-# frozen_string_literal: true
-require 'spec_helper'
-
-RSpec.describe 'shared/_gl_toggle.html.haml' do
- context 'defaults' do
- before do
- render partial: 'shared/gl_toggle', locals: {
- classes: '.js-gl-toggle'
- }
- end
-
- it 'does not set a name' do
- expect(rendered).not_to have_selector('[data-name]')
- end
-
- it 'sets default is-checked attributes' do
- expect(rendered).to have_selector('[data-is-checked="false"]')
- end
-
- it 'sets default disabled attributes' do
- expect(rendered).to have_selector('[data-disabled="false"]')
- end
-
- it 'sets default is-loading attributes' do
- expect(rendered).to have_selector('[data-is-loading="false"]')
- end
-
- it 'does not set a label' do
- expect(rendered).not_to have_selector('[data-label]')
- end
-
- it 'does not set a label position' do
- expect(rendered).not_to have_selector('[data-label-position]')
- end
- end
-
- context 'with custom options' do
- before do
- render partial: 'shared/gl_toggle', locals: {
- classes: 'js-custom-gl-toggle',
- name: 'toggle-name',
- is_checked: true,
- disabled: true,
- is_loading: true,
- label: 'Custom label',
- label_position: 'top',
- data: {
- foo: 'bar'
- }
- }
- end
-
- it 'sets the custom class' do
- expect(rendered).to have_selector('.js-custom-gl-toggle')
- end
-
- it 'sets the custom name' do
- expect(rendered).to have_selector('[data-name="toggle-name"]')
- end
-
- it 'sets the custom is-checked attributes' do
- expect(rendered).to have_selector('[data-is-checked="true"]')
- end
-
- it 'sets the custom disabled attributes' do
- expect(rendered).to have_selector('[data-disabled="true"]')
- end
-
- it 'sets the custom is-loading attributes' do
- expect(rendered).to have_selector('[data-is-loading="true"]')
- end
-
- it 'sets the custom label' do
- expect(rendered).to have_selector('[data-label="Custom label"]')
- end
-
- it 'sets the cutom label position' do
- expect(rendered).to have_selector('[data-label-position="top"]')
- end
-
- it 'sets cutom data attributes' do
- expect(rendered).to have_selector('[data-foo="bar"]')
- end
- end
-end
diff --git a/spec/views/shared/_global_alert.html.haml_spec.rb b/spec/views/shared/_global_alert.html.haml_spec.rb
index 84198cbb75e..a400d5b39b0 100644
--- a/spec/views/shared/_global_alert.html.haml_spec.rb
+++ b/spec/views/shared/_global_alert.html.haml_spec.rb
@@ -43,33 +43,4 @@ RSpec.describe 'shared/_global_alert.html.haml' do
expect(rendered).not_to have_selector('.gl-dismiss-btn')
end
end
-
- context 'fixed layout' do
- before do
- allow(view).to receive(:fluid_layout).and_return(false)
- end
-
- it 'adds container classes' do
- render
-
- expect(rendered).to have_selector('.container-fluid.container-limited')
- end
-
- it 'does not add container classes if is_contained is true' do
- render partial: 'shared/global_alert', locals: { is_contained: true }
-
- expect(rendered).not_to have_selector('.container-fluid.container-limited')
- end
- end
-
- context 'fluid layout' do
- before do
- allow(view).to receive(:fluid_layout).and_return(true)
- render
- end
-
- it 'does not add container classes' do
- expect(rendered).not_to have_selector('.container-fluid.container-limited')
- end
- end
end
diff --git a/spec/views/shared/issuable/_sidebar.html.haml_spec.rb b/spec/views/shared/issuable/_sidebar.html.haml_spec.rb
index 2097b8890cc..43a723dbb2c 100644
--- a/spec/views/shared/issuable/_sidebar.html.haml_spec.rb
+++ b/spec/views/shared/issuable/_sidebar.html.haml_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe 'shared/issuable/_sidebar.html.haml' do
end
context 'project in a group' do
- let_it_be(:group) { create(:group) }
+ let_it_be(:group) { create(:group, :crm_enabled) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:incident) { create(:incident, project: project) }
@@ -35,5 +35,34 @@ RSpec.describe 'shared/issuable/_sidebar.html.haml' do
expect(rendered).not_to have_css('[data-testid="escalation_status_container"]')
end
end
+
+ context 'crm contacts widget' do
+ let(:issuable) { issue }
+
+ context 'without permission' do
+ it 'is expected not to be shown' do
+ create(:contact, group: group)
+
+ expect(rendered).not_to have_css('#js-issue-crm-contacts')
+ end
+ end
+
+ context 'without contacts' do
+ it 'is expected not to be shown' do
+ group.add_developer(user)
+
+ expect(rendered).not_to have_css('#js-issue-crm-contacts')
+ end
+ end
+
+ context 'with permission and contacts' do
+ it 'is expected to be shown' do
+ create(:contact, group: group)
+ group.add_developer(user)
+
+ expect(rendered).to have_css('#js-issue-crm-contacts')
+ end
+ end
+ end
end
end
diff --git a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
index bf050d601e3..0e7b657a154 100644
--- a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
+++ b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe 'shared/wikis/_sidebar.html.haml' do
context 'The sidebar comes from a custom page' do
before do
- assign(:sidebar_page, double('WikiPage', path: 'sidebar.md', slug: 'sidebar', content: 'Some sidebar content'))
+ assign(:sidebar_page, double('WikiPage', path: 'sidebar.md', slug: 'sidebar', content: 'Some sidebar content', wiki: wiki))
end
it 'does not show an alert' do