gitlab-org--gitlab-foss/spec/controllers/admin/appearances_controller_spec.rb
Alexandru Croitor 77985826d9 Show header and footer system messages in email
* Add email_header_and_footer_enabled flag to appearances table
* Set email_header_and_footer_enabled default value to false
* Add checkbox to appearance to toggle show header and footer in emails
* Add email_header_and_footer_enabled to allowed params in controller
* Add header and footer messages to the html and text email layouts
* Remove the color styling for emails header and footer
* Add empty_mailer layout for emails without layout,
to have the header and footer applied
2019-02-27 22:07:50 +02:00

91 lines
2.4 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Admin::AppearancesController do
let(:admin) { create(:admin) }
let(:header_message) { 'Header message' }
let(:footer_message) { 'Footer' }
describe 'POST #create' do
let(:create_params) do
{
title: 'Foo',
description: 'Bar',
header_message: header_message,
footer_message: footer_message
}
end
before do
sign_in(admin)
end
it 'creates appearance with footer and header message' do
post :create, params: { appearance: create_params }
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: false,
message_background_color: '#E75E40',
message_font_color: '#FFFFFF'
)
end
context 'when enabling header and footer in email' do
it 'creates appearance with enabled flag' do
create_params[:email_header_and_footer_enabled] = true
post :create, params: { appearance: create_params }
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: true
)
end
end
end
describe 'PUT #update' do
let(:update_params) do
{
header_message: header_message,
footer_message: footer_message
}
end
before do
create(:appearance)
sign_in(admin)
end
it 'updates appearance with footer and header message' do
put :update, params: { appearance: update_params }
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: false,
message_background_color: '#E75E40',
message_font_color: '#FFFFFF'
)
end
context 'when enabling header and footer in email' do
it 'updates appearance with enabled flag' do
update_params[:email_header_and_footer_enabled] = true
post :update, params: { appearance: update_params }
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: true
)
end
end
end
end