mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-15 20:54:03 +00:00
75 lines
2.3 KiB
Ruby
75 lines
2.3 KiB
Ruby
require 'spec_helper'
|
|
|
|
feature Photo do
|
|
|
|
# It is necessary to use bang version of let to build roles before user
|
|
let!(:organizer_role) { create(:organizer_role) }
|
|
let!(:participant_role) { create(:participant_role) }
|
|
let!(:admin_role) { create(:admin_role) }
|
|
|
|
shared_examples 'add and update photo' do |user|
|
|
scenario 'adds a new photo', feature: true, js: true do
|
|
expected_count = Photo.count + 1
|
|
conference = create(:conference)
|
|
sign_in create(user)
|
|
|
|
visit new_admin_conference_photo_path(conference.short_title)
|
|
|
|
file_path = Rails.root.join('app', 'assets', 'images', 'rails.png')
|
|
attach_file('photo_picture', file_path)
|
|
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
|
|
|
click_button 'Save Photo'
|
|
|
|
expect(flash).
|
|
to eq('Photo was successfully created.')
|
|
expect(Photo.count).to eq(expected_count)
|
|
end
|
|
|
|
scenario 'updates a photo', feature: true, js: true do
|
|
expected_count = Photo.count + 1
|
|
conference = create(:conference)
|
|
photo = create(:photo)
|
|
sign_in create(user)
|
|
|
|
visit edit_admin_conference_photo_path(conference.short_title, photo.id)
|
|
|
|
file_path = Rails.root.join('app', 'assets', 'images', 'person_large.png')
|
|
attach_file('photo_picture', file_path)
|
|
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
|
|
|
click_button 'Save Photo'
|
|
|
|
expect(flash).
|
|
to eq('Photo was successfully updated.')
|
|
expect(Photo.count).to eq(expected_count)
|
|
end
|
|
|
|
scenario 'adds a text file', feature: true, js: true do
|
|
expected_count = Photo.count
|
|
conference = create(:conference)
|
|
sign_in create(user)
|
|
|
|
visit new_admin_conference_photo_path(conference.short_title)
|
|
|
|
file_path = Rails.root + 'spec/fixtures/test.txt'
|
|
attach_file('photo_picture', file_path)
|
|
fill_in 'photo_description', with: 'Lorem ipsum dolorem...'
|
|
|
|
click_button 'Save Photo'
|
|
|
|
expect(flash).
|
|
to eq("A error prohibited this Photo from being saved: Picture content type is invalid. Picture is invalid.")
|
|
expect(Photo.count).to eq(expected_count)
|
|
end
|
|
end
|
|
|
|
describe 'admin' do
|
|
it_behaves_like 'add and update photo', :admin
|
|
end
|
|
|
|
describe 'organizer' do
|
|
it_behaves_like 'add and update photo', :organizer
|
|
end
|
|
|
|
end
|