2016-12-13 10:22:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
feature 'Admin Appearance' do
|
2016-12-13 10:22:18 -05:00
|
|
|
let!(:appearance) { create(:appearance) }
|
|
|
|
|
|
|
|
scenario 'Create new appearance' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-13 10:22:18 -05:00
|
|
|
visit admin_appearances_path
|
|
|
|
|
|
|
|
fill_in 'appearance_title', with: 'MyCompany'
|
|
|
|
fill_in 'appearance_description', with: 'dev server'
|
2017-11-22 08:48:38 -05:00
|
|
|
fill_in 'appearance_new_project_guidelines', with: 'Custom project guidelines'
|
2016-12-13 10:22:18 -05:00
|
|
|
click_button 'Save'
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_appearances_path
|
|
|
|
expect(page).to have_content 'Appearance settings'
|
|
|
|
|
|
|
|
expect(page).to have_field('appearance_title', with: 'MyCompany')
|
|
|
|
expect(page).to have_field('appearance_description', with: 'dev server')
|
2017-11-22 08:48:38 -05:00
|
|
|
expect(page).to have_field('appearance_new_project_guidelines', with: 'Custom project guidelines')
|
2016-12-13 10:22:18 -05:00
|
|
|
expect(page).to have_content 'Last edit'
|
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
scenario 'Preview sign-in page appearance' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-13 10:22:18 -05:00
|
|
|
|
|
|
|
visit admin_appearances_path
|
2017-11-22 08:48:38 -05:00
|
|
|
click_link "Sign-in page"
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Preview new project page appearance' do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
|
|
|
|
visit admin_appearances_path
|
|
|
|
click_link "New project page"
|
|
|
|
|
|
|
|
expect_custom_new_project_appearance(appearance)
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Custom sign-in page' do
|
|
|
|
visit new_user_session_path
|
2017-11-22 08:48:38 -05:00
|
|
|
|
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Custom new project page' do
|
|
|
|
sign_in create(:user)
|
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
expect_custom_new_project_appearance(appearance)
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Appearance logo' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-13 10:22:18 -05:00
|
|
|
visit admin_appearances_path
|
|
|
|
|
|
|
|
attach_file(:appearance_logo, logo_fixture)
|
|
|
|
click_button 'Save'
|
|
|
|
expect(page).to have_css(logo_selector)
|
|
|
|
|
|
|
|
click_link 'Remove logo'
|
|
|
|
expect(page).not_to have_css(logo_selector)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Header logos' do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-13 10:22:18 -05:00
|
|
|
visit admin_appearances_path
|
|
|
|
|
|
|
|
attach_file(:appearance_header_logo, logo_fixture)
|
|
|
|
click_button 'Save'
|
|
|
|
expect(page).to have_css(header_logo_selector)
|
|
|
|
|
|
|
|
click_link 'Remove header logo'
|
|
|
|
expect(page).not_to have_css(header_logo_selector)
|
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def expect_custom_sign_in_appearance(appearance)
|
2016-12-13 10:22:18 -05:00
|
|
|
expect(page).to have_content appearance.title
|
|
|
|
expect(page).to have_content appearance.description
|
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def expect_custom_new_project_appearance(appearance)
|
|
|
|
expect(page).to have_content appearance.new_project_guidelines
|
|
|
|
end
|
|
|
|
|
2016-12-13 10:22:18 -05:00
|
|
|
def logo_selector
|
2017-07-24 13:36:52 -04:00
|
|
|
'//img[data-src^="/uploads/-/system/appearance/logo"]'
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def header_logo_selector
|
2017-07-24 13:36:52 -04:00
|
|
|
'//img[data-src^="/uploads/-/system/appearance/header_logo"]'
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def logo_fixture
|
|
|
|
Rails.root.join('spec', 'fixtures', 'dk.png')
|
|
|
|
end
|
|
|
|
end
|