Commit ca71cb1f authored by Martin Markech's avatar Martin Markech
Browse files

tests for photos

parent 20aec05d
...@@ -253,9 +253,16 @@ Remove fancybox init javascript from _javascripts.html.erb file ...@@ -253,9 +253,16 @@ Remove fancybox init javascript from _javascripts.html.erb file
Remove gem from Gemfile Remove gem from Gemfile
## Testing
* cd to this engine path
* bundle install
* rake refinery:testing:dummy_app
* rake spec
* Probably you will need to set some asset manifest to dummy's app manifest - see console output for errors
## Todo list ## Todo list
* create app tests
* show live links in admin * show live links in admin
* create pop-up window to upload photos from pages area, like page-images * create pop-up window to upload photos from pages area, like page-images
* add checkboxes to delete multiple/all photos in album * add checkboxes to delete multiple/all photos in album
...@@ -278,9 +285,9 @@ file extensions to upload queue. ( But server side validation reject these files ...@@ -278,9 +285,9 @@ file extensions to upload queue. ( But server side validation reject these files
* album/photo tags using acts_as_taggable ? * album/photo tags using acts_as_taggable ?
* show photo location on google maps ? * show photo location on google maps ?
## Testing
TODO
## License ## License
......
...@@ -51,6 +51,9 @@ module Refinery ...@@ -51,6 +51,9 @@ module Refinery
if @photo.destroy if @photo.destroy
respond_to do |format| respond_to do |format|
format.html {
redirect_to refinery.photo_gallery_admin_albums_path
}
format.js { format.js {
render :partial=> "destroy", :locals => {:photo => @photo} render :partial=> "destroy", :locals => {:photo => @photo}
} }
......
...@@ -56,20 +56,6 @@ module Refinery ...@@ -56,20 +56,6 @@ module Refinery
end end
=begin
#TODO add checkbox to check if it should be writed to exif, globally on/off writing
def exif_write
# should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file
photo = MiniExiftool.new(self.file.file.file)
photo.GPSLongitude = self.longitude
photo.GPSLatitude = self.latitude
photo.DocumentName = self.title
photo.ImageDescription = self.description
photo.Keywords = self.tags
photo.save
end
=end
end end
end end
end end
......
...@@ -4,5 +4,20 @@ FactoryGirl.define do ...@@ -4,5 +4,20 @@ FactoryGirl.define do
path "15_04" path "15_04"
description "describtion about album" description "describtion about album"
address "slovakia" address "slovakia"
factory :album_with_photos do
transient do
photos_count 5
end
# the after(:create) yields two values; the user instance itself and the
# evaluator, which stores all values from the factory, including transient
# attributes; `create_list`'s second argument is the number of records
# to create and we make sure the user is associated properly to the post
after(:create) do |album, evaluator|
create_list(:photo, evaluator.photos_count, album: album)
end
end
end end
end end
\ No newline at end of file
FactoryGirl.define do FactoryGirl.define do
factory :photo, class: Refinery::PhotoGallery::Photo do factory :photo, class: Refinery::PhotoGallery::Photo do
title "Photo"
description "description"
path "16_04"
#sequence(:title){|n| "Photo-#{n}" } #sequence(:title){|n| "Photo-#{n}" }
#file { Rack::Test::UploadedFile.new( File.open(File.join(File.join(Refinery.roots(:'refinery/photo_gallery'), 'spec', 'support', 'images', 'refinery-logo-trans.png'))), "image/png" ) } file { Rack::Test::UploadedFile.new( File.open(File.join(File.join(Refinery.roots(:'refinery/photo_gallery'), 'spec', 'support', 'images', 'refinery-logo-trans.png'))), "image/png" ) }
end end
end end
......
require "spec_helper"
describe "manage photo items", :type => :feature do
refinery_login_with_devise :authentication_devise_refinery_superuser
describe "edit/update" do
before do
FactoryGirl.create(:album_with_photos, :title => "Album name")
end
it "updates photo" do
visit refinery.photo_gallery_admin_albums_path
expect(page).to have_content("Album name")
click_link "Edit photos in album"
fill_in "photos_photo_5_title", :with => "Updated title 5"
fill_in "photos_photo_4_title", :with => "Updated title 4"
fill_in "photos_photo_3_title", :with => "Updated title 3"
fill_in "photos_photo_2_title", :with => "Updated title 2"
fill_in "photos_photo_1_title", :with => "Updated title 1"
click_button "Save"
expect(page).to have_content("Updated photos")
end
end
describe "destroy" do
before do
FactoryGirl.create(:album_with_photos, :title => "Album name")
end
it "removes photo" do
visit refinery.photo_gallery_admin_albums_path
expect(page).to have_content("Album name")
click_link "Edit photos in album"
first(:link, "Remove").click
expect(Refinery::PhotoGallery::Photo.count).to eq(4)
end
end
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment