diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 12:09:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-17 12:09:53 +0300 |
commit | 612bb6f624ea7fdf5fd20e3332d543191603db88 (patch) | |
tree | 0540ef31b097382b8fd974cc4c41d1938d8caae4 /spec/views/shared | |
parent | af4364040394d0261c8b1c5f78ca60cc1e68e43c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/views/shared')
-rw-r--r-- | spec/views/shared/_global_alert.html.haml_spec.rb | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/spec/views/shared/_global_alert.html.haml_spec.rb b/spec/views/shared/_global_alert.html.haml_spec.rb new file mode 100644 index 00000000000..7eec068645a --- /dev/null +++ b/spec/views/shared/_global_alert.html.haml_spec.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe 'shared/_global_alert.html.haml' do + before do + allow(view).to receive(:sprite_icon).and_return('<span class="icon"></span>'.html_safe) + end + + it 'renders the title' do + title = "The alert's title" + render partial: 'shared/global_alert', locals: { title: title } + + expect(rendered).to have_text(title) + end + + context 'variants' do + it 'renders an info alert by default' do + render + + expect(rendered).to have_selector(".gl-alert-info") + end + + %w[warning success danger tip].each do |variant| + it "renders a #{variant} variant" do + allow(view).to receive(:variant).and_return(variant) + render partial: 'shared/global_alert', locals: { variant: variant } + + expect(rendered).to have_selector(".gl-alert-#{variant}") + end + end + end + + context 'dismissible option' do + it 'shows the dismiss button by default' do + render + + expect(rendered).to have_selector('.gl-dismiss-btn') + end + + it 'does not show the dismiss button when dismissible is false' do + render partial: 'shared/global_alert', locals: { dismissible: false } + + 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 'does not add layout limited class' do + render + + expect(rendered).not_to have_selector('.gl-alert-layout-limited') + 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 'adds layout limited class' do + expect(rendered).to have_selector('.gl-alert-layout-limited') + end + + it 'does not add container classes' do + expect(rendered).not_to have_selector('.container-fluid.container-limited') + end + end +end |