debian-mirror-gitlab/spec/features/admin/admin_appearance_spec.rb

154 lines
4.4 KiB
Ruby
Raw Normal View History

2019-09-04 21:01:54 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2018-11-08 19:23:39 +05:30
describe 'Admin Appearance' do
2017-08-17 22:00:37 +05:30
let!(:appearance) { create(:appearance) }
2018-11-08 19:23:39 +05:30
it 'Create new appearance' do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2017-08-17 22:00:37 +05:30
visit admin_appearances_path
fill_in 'appearance_title', with: 'MyCompany'
fill_in 'appearance_description', with: 'dev server'
2018-03-17 18:26:18 +05:30
fill_in 'appearance_new_project_guidelines', with: 'Custom project guidelines'
2019-03-02 22:35:43 +05:30
click_button 'Update appearance settings'
2017-08-17 22:00:37 +05:30
expect(current_path).to eq admin_appearances_path
2019-03-02 22:35:43 +05:30
expect(page).to have_content 'Appearance'
2017-08-17 22:00:37 +05:30
expect(page).to have_field('appearance_title', with: 'MyCompany')
expect(page).to have_field('appearance_description', with: 'dev server')
2018-03-17 18:26:18 +05:30
expect(page).to have_field('appearance_new_project_guidelines', with: 'Custom project guidelines')
2017-08-17 22:00:37 +05:30
expect(page).to have_content 'Last edit'
end
2018-11-08 19:23:39 +05:30
it 'Preview sign-in page appearance' do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2017-08-17 22:00:37 +05:30
visit admin_appearances_path
2018-03-17 18:26:18 +05:30
click_link "Sign-in page"
2017-08-17 22:00:37 +05:30
2018-03-17 18:26:18 +05:30
expect_custom_sign_in_appearance(appearance)
end
2018-11-08 19:23:39 +05:30
it 'Preview new project page appearance' do
2018-03-17 18:26:18 +05:30
sign_in(create(:admin))
visit admin_appearances_path
click_link "New project page"
expect_custom_new_project_appearance(appearance)
2017-08-17 22:00:37 +05:30
end
2019-07-07 11:18:12 +05:30
context 'Custom system header and footer' do
before do
sign_in(create(:admin))
end
context 'when system header and footer messages are empty' do
it 'shows custom system header and footer fields' do
visit admin_appearances_path
expect(page).to have_field('appearance_header_message', with: '')
expect(page).to have_field('appearance_footer_message', with: '')
expect(page).to have_field('appearance_message_background_color')
expect(page).to have_field('appearance_message_font_color')
end
end
context 'when system header and footer messages are not empty' do
before do
appearance.update(header_message: 'Foo', footer_message: 'Bar')
end
it 'shows custom system header and footer fields' do
visit admin_appearances_path
expect(page).to have_field('appearance_header_message', with: appearance.header_message)
expect(page).to have_field('appearance_footer_message', with: appearance.footer_message)
expect(page).to have_field('appearance_message_background_color')
expect(page).to have_field('appearance_message_font_color')
end
end
end
2018-11-08 19:23:39 +05:30
it 'Custom sign-in page' do
2017-08-17 22:00:37 +05:30
visit new_user_session_path
2018-03-17 18:26:18 +05:30
expect_custom_sign_in_appearance(appearance)
end
2018-11-08 19:23:39 +05:30
it 'Custom new project page' do
2018-03-17 18:26:18 +05:30
sign_in create(:user)
visit new_project_path
expect_custom_new_project_appearance(appearance)
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it 'Appearance logo' do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2017-08-17 22:00:37 +05:30
visit admin_appearances_path
attach_file(:appearance_logo, logo_fixture)
2019-03-02 22:35:43 +05:30
click_button 'Update appearance settings'
2017-08-17 22:00:37 +05:30
expect(page).to have_css(logo_selector)
click_link 'Remove logo'
expect(page).not_to have_css(logo_selector)
end
2018-11-08 19:23:39 +05:30
it 'Header logos' do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2017-08-17 22:00:37 +05:30
visit admin_appearances_path
attach_file(:appearance_header_logo, logo_fixture)
2019-03-02 22:35:43 +05:30
click_button 'Update appearance settings'
2017-08-17 22:00:37 +05:30
expect(page).to have_css(header_logo_selector)
click_link 'Remove header logo'
expect(page).not_to have_css(header_logo_selector)
end
2018-11-08 19:23:39 +05:30
it 'Favicon' do
sign_in(create(:admin))
visit admin_appearances_path
attach_file(:appearance_favicon, logo_fixture)
2019-03-02 22:35:43 +05:30
click_button 'Update appearance settings'
2018-11-08 19:23:39 +05:30
expect(page).to have_css('.appearance-light-logo-preview')
click_link 'Remove favicon'
expect(page).not_to have_css('.appearance-light-logo-preview')
# allowed file types
attach_file(:appearance_favicon, Rails.root.join('spec', 'fixtures', 'sanitized.svg'))
2019-03-02 22:35:43 +05:30
click_button 'Update appearance settings'
2018-11-08 19:23:39 +05:30
expect(page).to have_content 'Favicon You are not allowed to upload "svg" files, allowed types: png, ico'
end
2018-03-17 18:26:18 +05:30
def expect_custom_sign_in_appearance(appearance)
2017-08-17 22:00:37 +05:30
expect(page).to have_content appearance.title
expect(page).to have_content appearance.description
end
2018-03-17 18:26:18 +05:30
def expect_custom_new_project_appearance(appearance)
expect(page).to have_content appearance.new_project_guidelines
end
2017-08-17 22:00:37 +05:30
def logo_selector
2017-09-10 17:25:29 +05:30
'//img[data-src^="/uploads/-/system/appearance/logo"]'
2017-08-17 22:00:37 +05:30
end
def header_logo_selector
2017-09-10 17:25:29 +05:30
'//img[data-src^="/uploads/-/system/appearance/header_logo"]'
2017-08-17 22:00:37 +05:30
end
def logo_fixture
Rails.root.join('spec', 'fixtures', 'dk.png')
end
end