2019-02-20 10:18:15 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-02 10:26:59 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe Admin::AppearancesController do
|
2018-04-02 10:26:59 -04:00
|
|
|
let(:admin) { create(:admin) }
|
2019-02-20 10:18:15 -05:00
|
|
|
let(:header_message) { 'Header message' }
|
|
|
|
let(:footer_message) { 'Footer' }
|
2018-04-02 10:26:59 -04:00
|
|
|
|
|
|
|
describe 'POST #create' do
|
|
|
|
let(:create_params) do
|
|
|
|
{
|
2019-02-20 10:18:15 -05:00
|
|
|
title: 'Foo',
|
|
|
|
description: 'Bar',
|
2018-04-02 10:26:59 -04:00
|
|
|
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,
|
2019-02-20 10:18:15 -05:00
|
|
|
footer_message: footer_message,
|
|
|
|
email_header_and_footer_enabled: false,
|
|
|
|
message_background_color: '#E75E40',
|
|
|
|
message_font_color: '#FFFFFF'
|
2018-04-02 10:26:59 -04:00
|
|
|
)
|
|
|
|
end
|
2019-02-20 10:18:15 -05:00
|
|
|
|
|
|
|
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
|
2018-04-02 10:26:59 -04:00
|
|
|
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,
|
2019-02-20 10:18:15 -05:00
|
|
|
footer_message: footer_message,
|
|
|
|
email_header_and_footer_enabled: false,
|
|
|
|
message_background_color: '#E75E40',
|
|
|
|
message_font_color: '#FFFFFF'
|
2018-04-02 10:26:59 -04:00
|
|
|
)
|
|
|
|
end
|
2019-02-20 10:18:15 -05:00
|
|
|
|
|
|
|
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
|
2018-04-02 10:26:59 -04:00
|
|
|
end
|
|
|
|
end
|