osem-fcy/spec/features/conference_spec.rb

61 lines
1.9 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
require 'spec_helper'
feature Conference do
let(:user) { create(:admin) }
describe 'admin' do
2024-06-07 16:31:23 +02:00
let(:conference) { create(:conference) }
scenario 'adds a new conference', feature: true, js: true do
expected_count = Conference.count + 1
2014-08-12 15:48:29 +03:00
sign_in user
visit new_admin_conference_path
fill_in 'conference_title', with: 'Example Con'
fill_in 'conference_short_title', with: 'ExCon'
2014-05-10 18:47:16 +02:00
select('(GMT+01:00) Berlin', from: 'conference[timezone]')
today = Time.zone.today - 1
fill_in 'conference_start_date', with: today.strftime('%Y/%m/%d')
fill_in 'conference_end_date', with: (today + 7).strftime('%Y/%m/%d')
click_button 'Create Conference'
within('#flash') { expect(page).to have_text('Conference was successfully created.') }
expect(Conference.count).to eq(expected_count)
user.reload
2022-03-30 12:39:01 +02:00
expect(user.has_cached_role? :organizer, Conference.last).to be(true)
end
scenario 'update conference', feature: true, js: true do
conference = create(:conference)
organizer = create(:organizer, resource: conference)
2014-08-12 15:48:29 +03:00
expected_count = Conference.count
2014-08-12 15:48:29 +03:00
sign_in organizer
visit edit_admin_conference_path(conference.short_title)
fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon'
day = Time.zone.today + 10
fill_in 'conference_start_date', with: day.strftime('%Y/%m/%d')
fill_in 'conference_end_date', with: (day + 7).strftime('%Y/%m/%d')
page.accept_alert do
click_button 'Update Conference'
end
within('#flash') { expect(page).to have_text('Conference was successfully updated.') }
conference.reload
expect(conference.title).to eq('New Con')
expect(conference.short_title).to eq('NewCon')
expect(Conference.count).to eq(expected_count)
end
end
end