Sha256: 8454e4120089f93dbd46e18c396a5e1e839baa8b51ad61cb66849ef79adf5292
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
require 'spec_helper' describe 'Events:', :js => true do def add_photo_to_form(attrs=nil) # attrs ||= build :photo last_tr = all('.polygallery-photos-table tr').last if last_tr.find('input[id$="_photo"]').value.present? page.execute_script <<-SCRIPT $('.btn.add_fields[data-association="photo"]').click(); SCRIPT last_tr = all('.polygallery-photos-table tr').last end within last_tr do find('input[id$="_photo"]').set Rails.root.join('spec', 'upload_files', 'logo_placeholder_medium.png') find('input[id$="_caption"]').set('Test test test') yield if block_given? end end describe 'with SimpleForm' do def complete_the_form(attrs=nil) attrs ||= attributes_for :event within 'form.simple_form.new_event' do fill_in 'Title', :with => attrs[:title] yield if block_given? click_button 'Create Event' end end def expect_success expect(page).to have_content 'Your event has been saved!' end def expect_failure expect(page).to have_content 'Your event could not be saved!' end it 'basically works' do visit root_path complete_the_form expect_success expect(Event.count).to eq 1 end it 'works when an image is attached' do visit root_path complete_the_form { add_photo_to_form } expect_success expect(Event.count).to eq 1 e = Event.last expect(e.custom_gallery_photos.count).to eq 1 photo = e.custom_gallery_photos.first puts photo expect(photo.photo.file?).to be true end end describe 'without SimpleForm' do it 'basically works' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polygallery-0.1.2 | test/dummy/spec/features/events_spec.rb |