Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created January 21, 2014 16:52
Show Gist options
  • Save nfriend21/8543656 to your computer and use it in GitHub Desktop.
Save nfriend21/8543656 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'PhotoGallery', :js => true do
before(:each) do
bootstrap
user_logs_in
@page = create_photo_gallery_page(@website)
visit "#{get_subdomain(@website)}/site_manager/pages"
click_page_link('photo_gallery_page1')
end
it 'manages a photo_gallery page' do
# edits a PhotoGallery by clicking on page name
current_path.should == edit_site_manager_photo_gallery_path(@page.pageable)
# uploads a photo
click_link('Albums & Photos')
VCR.use_cassette 'product-upload', :record => :new_episodes do
page.execute_script("$('.cloudinary-fileupload, .hidden-upload-input').css({ 'visibility': 'visible', 'display': 'block' })")
attach_file('file', "#{Rails.root}/app/assets/images/image_for_testing.jpg")
page.find('.ajax-completed')
end
Photo.last.title.should =~ /image-for-testing/
# displays an albumless photo on the photo gallery page of the users website
visit "#{get_subdomain(@website)}/#{@page.slug}"
page.find("#photo_#{Photo.last.id}")
page.find(:xpath, "//img[contains(@src, 'image')]")
# deletes a photo
visit "#{get_subdomain(@website)}/photo_galleries/#{@page.pageable.id}/edit"
click_link('Albums & Photos')
VCR.use_cassette 'product-upload', :record => :new_episodes do
page.execute_script("$('.cloudinary-fileupload, .hidden-upload-input').css({ 'visibility': 'visible', 'display': 'block' })")
attach_file('file', "#{Rails.root}/app/assets/images/image_for_testing.jpg")
page.find('.ajax-completed')
end
photo = Photo.last
click_link('Albums & Photos')
page.execute_script "window.scrollBy(0,10000)"
click_link "delete"
page.driver.browser.switch_to.alert.accept #clicks ok on the confirmation pop-up
page.find('.ajax-completed')
# updates
click_link('Info')
fill_in 'Name', :with => 'photogallerypage1_edited'
click_save_on_site_controls
page.find(:css, '.ajax-overlay-confirmation').should be_visible
Page.last.name.should == 'photogallerypage1_edited'
# saves CustomPageStyle nested attributes
click_save_on_site_controls
page.find(:css, '.ajax-overlay-confirmation').should be_visible
PhotoGallery.last.style_choice.should == 'default'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment