2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2014-05-15 13:23:14 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
feature DifficultyLevel do
|
2014-08-12 15:48:29 +03:00
|
|
|
let!(:conference) { create(:conference) }
|
2019-03-13 10:31:42 +01:00
|
|
|
let!(:organizer) { create(:organizer, resource: conference) }
|
2014-05-15 13:23:14 +02:00
|
|
|
|
2014-08-12 15:48:29 +03:00
|
|
|
shared_examples 'difficulty levels' do
|
2014-11-25 10:47:18 +01:00
|
|
|
scenario 'adds difficulty level', feature: true, js: true do
|
2014-08-12 15:48:29 +03:00
|
|
|
|
|
|
|
|
sign_in organizer
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_difficulty_levels_path(
|
2014-05-15 13:23:14 +02:00
|
|
|
conference_id: conference.short_title)
|
|
|
|
|
|
|
|
|
|
# Add difficulty level
|
2014-11-25 10:47:18 +01:00
|
|
|
click_link 'Add Difficulty Level'
|
2014-05-15 13:23:14 +02:00
|
|
|
|
2014-11-25 10:47:18 +01:00
|
|
|
fill_in 'difficulty_level_title', with: 'Hard'
|
|
|
|
|
fill_in 'difficulty_level_description', with: 'Life is the hardest'
|
|
|
|
|
page.find('#difficulty_level_color').set('#ff0000')
|
|
|
|
|
click_button 'Create Difficulty level'
|
2025-08-06 13:04:53 +02:00
|
|
|
|
|
|
|
|
within('#flash') { expect(page).to have_text('Difficulty level successfully created.') }
|
2014-11-25 10:47:18 +01:00
|
|
|
within('table#difficulty_levels') do
|
|
|
|
|
expect(page.has_content?('Hard')).to be true
|
|
|
|
|
expect(page.has_content?('Life is the hardest')).to be true
|
2014-12-05 16:04:34 +01:00
|
|
|
expect(page.assert_selector('tr', count: 5)).to be true
|
2014-11-25 10:47:18 +01:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'updates difficulty level', feature: true, js: true do
|
|
|
|
|
|
2015-10-25 13:29:02 +02:00
|
|
|
conference.program.difficulty_levels << create(:difficulty_level)
|
2014-11-25 10:47:18 +01:00
|
|
|
sign_in organizer
|
2015-10-25 13:29:02 +02:00
|
|
|
visit admin_conference_program_difficulty_levels_path(
|
2014-11-25 10:47:18 +01:00
|
|
|
conference_id: conference.short_title)
|
2014-05-15 13:23:14 +02:00
|
|
|
|
|
|
|
|
# Remove difficulty level
|
2018-10-25 16:16:56 -07:00
|
|
|
page.accept_alert do
|
|
|
|
|
within('table tr:nth-of-type(4)') do
|
|
|
|
|
click_link 'Delete'
|
|
|
|
|
end
|
2014-12-05 16:04:34 +01:00
|
|
|
end
|
2014-11-25 10:47:18 +01:00
|
|
|
|
2025-08-06 13:04:53 +02:00
|
|
|
within('#flash') { expect(page).to have_text('Difficulty level successfully deleted.') }
|
2014-11-25 10:47:18 +01:00
|
|
|
within('table#difficulty_levels') do
|
2014-12-05 16:04:34 +01:00
|
|
|
expect(page.assert_selector('tr', count: 4)).to be true
|
|
|
|
|
expect(page.has_content?('Easy Events')).to be true
|
|
|
|
|
expect(page.has_content?('Medium Events')).to be true
|
|
|
|
|
expect(page.has_content?('Hard Events')).to be true
|
2014-11-25 10:47:18 +01:00
|
|
|
end
|
2014-05-15 13:23:14 +02:00
|
|
|
end
|
2014-11-25 10:47:18 +01:00
|
|
|
|
2014-05-15 13:23:14 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'organizer' do
|
2014-08-12 15:48:29 +03:00
|
|
|
it_behaves_like 'difficulty levels'
|
2014-05-15 13:23:14 +02:00
|
|
|
end
|
|
|
|
|
end
|