appearance.rb 2.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
  include SharedAuthentication
  include SharedPaths

  step 'submit form with new appearance' do
    fill_in 'appearance_title', with: 'MyCompany'
    fill_in 'appearance_description', with: 'dev server'
    click_button 'Save'
  end

  step 'I should be redirected to admin appearance page' do
    expect(current_path).to eq admin_appearances_path
    expect(page).to have_content 'Appearance settings'
  end

  step 'I should see newly created appearance' do
    expect(page).to have_field('appearance_title', with: 'MyCompany')
    expect(page).to have_field('appearance_description', with: 'dev server')
    expect(page).to have_content 'Last edit'
  end

  step 'I click preview button' do
    click_link "Preview"
  end

  step 'application has custom appearance' do
    create(:appearance)
  end

  step 'I should see a customized appearance' do
    expect(page).to have_content appearance.title
    expect(page).to have_content appearance.description
  end

  step 'I attach a logo' do
    attach_file(:appearance_logo, Rails.root.join('spec', 'fixtures', 'dk.png'))
    click_button 'Save'
  end

  step 'I attach header logos' do
    attach_file(:appearance_header_logo, Rails.root.join('spec', 'fixtures', 'dk.png'))
    click_button 'Save'
  end

  step 'I should see a logo' do
    expect(page).to have_xpath('//img[@src="/uploads/appearance/logo/1/dk.png"]')
  end

  step 'I should see header logos' do
    expect(page).to have_xpath('//img[@src="/uploads/appearance/header_logo/1/dk.png"]')
  end

  step 'I remove the logo' do
    click_link 'Remove logo'
  end

  step 'I remove the header logos' do
    click_link 'Remove header logo'
  end

  step 'I should see logo removed' do
    expect(page).not_to have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
  end

  step 'I should see header logos removed' do
    expect(page).not_to have_xpath('//img[@src="/uploads/appearance/header_logo/1/header_logo_light.png"]')
  end

  def appearance
    Appearance.last
  end
end