comfy_gallery 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.travis.yml +2 -0
- data/Gemfile +10 -0
- data/LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/app/assets/images/sofa_gallery/jcrop.gif +0 -0
- data/app/assets/images/sofa_gallery/orbit/bullets.jpg +0 -0
- data/app/assets/images/sofa_gallery/orbit/left-arrow.png +0 -0
- data/app/assets/images/sofa_gallery/orbit/loading.gif +0 -0
- data/app/assets/images/sofa_gallery/orbit/mask-black.png +0 -0
- data/app/assets/images/sofa_gallery/orbit/pause-black.png +0 -0
- data/app/assets/images/sofa_gallery/orbit/right-arrow.png +0 -0
- data/app/assets/images/sofa_gallery/orbit/rotator-black.png +0 -0
- data/app/assets/images/sofa_gallery/orbit/timer-black.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/contentPattern.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/contentPattern.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/dark_square/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/default_thumb.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_next.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_prev.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_x.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/default/sprite_y.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternBottom.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternLeft.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternRight.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternTop.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/facebook/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_rounded/sprite.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/btnNext.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/btnPrevious.png +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/default_thumbnail.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/loader.gif +0 -0
- data/app/assets/images/sofa_gallery/prettyPhoto/light_square/sprite.png +0 -0
- data/app/assets/javascripts/sofa_gallery/admin.js +72 -0
- data/app/assets/javascripts/sofa_gallery/application.js +15 -0
- data/app/assets/javascripts/sofa_gallery/jquery.jcrop.js +246 -0
- data/app/assets/javascripts/sofa_gallery/jquery.orbit-1.2.3.min.js +17 -0
- data/app/assets/javascripts/sofa_gallery/thumbnails.js +85 -0
- data/app/assets/stylesheets/comfy_gallery/admin.css +57 -0
- data/app/assets/stylesheets/comfy_gallery/application.css +67 -0
- data/app/assets/stylesheets/comfy_gallery/carousel.css.erb +208 -0
- data/app/assets/stylesheets/comfy_gallery/gallery_list.css +18 -0
- data/app/assets/stylesheets/comfy_gallery/jquery.jcrop.css +32 -0
- data/app/assets/stylesheets/comfy_gallery/reset.css +1 -0
- data/app/assets/stylesheets/comfy_gallery/thumbnails.css.erb +181 -0
- data/app/controllers/admin/gallery/base_controller.rb +3 -0
- data/app/controllers/admin/gallery/galleries_controller.rb +63 -0
- data/app/controllers/admin/gallery/photos_controller.rb +96 -0
- data/app/controllers/application_controller.rb +7 -0
- data/app/controllers/gallery/galleries_controller.rb +15 -0
- data/app/helpers/gallery/application_helper.rb +30 -0
- data/app/models/gallery/gallery.rb +19 -0
- data/app/models/gallery/photo.rb +78 -0
- data/app/views/admin/gallery/_html_head.html.erb +1 -0
- data/app/views/admin/gallery/_navigation.html.erb +5 -0
- data/app/views/admin/gallery/galleries/_form.html.erb +18 -0
- data/app/views/admin/gallery/galleries/edit.html.erb +5 -0
- data/app/views/admin/gallery/galleries/index.html.erb +40 -0
- data/app/views/admin/gallery/galleries/new.html.erb +5 -0
- data/app/views/admin/gallery/photos/_form.html.erb +16 -0
- data/app/views/admin/gallery/photos/crop.html.erb +64 -0
- data/app/views/admin/gallery/photos/edit.html.erb +5 -0
- data/app/views/admin/gallery/photos/index.html.erb +24 -0
- data/app/views/admin/gallery/photos/new.html.erb +5 -0
- data/app/views/gallery/_carousel.html.erb +31 -0
- data/app/views/gallery/_list_galleries.html.erb +26 -0
- data/app/views/gallery/_thumbnails.html.erb +26 -0
- data/app/views/gallery/galleries/index.html.erb +1 -0
- data/app/views/gallery/galleries/show.html.erb +7 -0
- data/app/views/layouts/gallery/application.html.erb +16 -0
- data/comfy_gallery.gemspec +177 -0
- data/config/application.rb +51 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +16 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +25 -0
- data/config/environments/production.rb +52 -0
- data/config/environments/test.rb +39 -0
- data/config/initializers/comfy_gallery.rb +15 -0
- data/config/initializers/paperclip.rb +3 -0
- data/config/routes.rb +17 -0
- data/config.ru +4 -0
- data/db/migrate/01_create_comfy_gallery.rb +36 -0
- data/lib/comfy_gallery/configuration.rb +26 -0
- data/lib/comfy_gallery/engine.rb +22 -0
- data/lib/comfy_gallery/form_builder.rb +50 -0
- data/lib/comfy_gallery.rb +23 -0
- data/lib/generators/README +10 -0
- data/lib/generators/comfy_gallery_generator.rb +33 -0
- data/lib/paperclip_processors/cropper.rb +31 -0
- data/lib/tasks/comfy_gallery.rake +4 -0
- data/script/rails +6 -0
- data/sofa_gallery.gemspec +175 -0
- data/test/fixtures/files/default.jpg +0 -0
- data/test/fixtures/files/default.txt +1 -0
- data/test/fixtures/files/default2.jpg +0 -0
- data/test/fixtures/gallery/galleries.yml +11 -0
- data/test/fixtures/gallery/photos.yml +9 -0
- data/test/functional/admin/gallery/galleries_controller_test.rb +87 -0
- data/test/functional/admin/gallery/photos_controller_test.rb +234 -0
- data/test/functional/gallery/galleries_controller_test.rb +24 -0
- data/test/test_helper.rb +39 -0
- data/test/unit/configuration_test.rb +18 -0
- data/test/unit/gallery_test.rb +33 -0
- data/test/unit/photo_test.rb +33 -0
- metadata +233 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
require File.expand_path('../../../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class Admin::Gallery::PhotosControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def test_get_index
|
|
6
|
+
get :index, :gallery_id => gallery_galleries(:default)
|
|
7
|
+
assert_response :success
|
|
8
|
+
assert_template 'index'
|
|
9
|
+
assert assigns(:photos)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_get_index_failure
|
|
13
|
+
get :index, :gallery_id => 'invalid'
|
|
14
|
+
assert_response :redirect
|
|
15
|
+
assert_redirected_to admin_gallery_galleries_path
|
|
16
|
+
assert_equal 'Gallery not found', flash[:error]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_new
|
|
20
|
+
gallery = gallery_galleries(:default)
|
|
21
|
+
get :new, :gallery_id => gallery
|
|
22
|
+
assert_response :success
|
|
23
|
+
assert_template 'new'
|
|
24
|
+
assert assigns(:photo)
|
|
25
|
+
assert_select "form[action='/admin/gallery/galleries/#{gallery.id}/photos']"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_create
|
|
29
|
+
assert_difference 'Gallery::Photo.count' do
|
|
30
|
+
post :create, :gallery_id => gallery_galleries(:default), :gallery_photo => {
|
|
31
|
+
:title => 'Test Photo',
|
|
32
|
+
:slug => 'test-photo',
|
|
33
|
+
:image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
|
|
34
|
+
}
|
|
35
|
+
assert_response :redirect
|
|
36
|
+
assert_redirected_to :action => :index
|
|
37
|
+
assert_equal 'Photo created', flash[:notice]
|
|
38
|
+
|
|
39
|
+
photo = Gallery::Photo.last
|
|
40
|
+
assert_equal 'Test Photo', photo.title
|
|
41
|
+
assert_equal 'test-photo', photo.slug
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_create_without_title_or_slug
|
|
46
|
+
assert_difference 'Gallery::Photo.count', 2 do
|
|
47
|
+
post :create, :gallery_id => gallery_galleries(:default), :gallery_photo => {
|
|
48
|
+
:image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
|
|
49
|
+
}
|
|
50
|
+
assert_response :redirect
|
|
51
|
+
assert_redirected_to :action => :index
|
|
52
|
+
assert_equal 'Photo created', flash[:notice]
|
|
53
|
+
|
|
54
|
+
photo = Gallery::Photo.last
|
|
55
|
+
assert_equal 'default.jpg', photo.title
|
|
56
|
+
assert_equal 'default-jpg', photo.slug
|
|
57
|
+
|
|
58
|
+
post :create, :gallery_id => gallery_galleries(:default), :gallery_photo => {
|
|
59
|
+
:slug => 'Testrrr',
|
|
60
|
+
:image => [fixture_file_upload('/files/default.jpg', 'image/jpeg')]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
photo = Gallery::Photo.last
|
|
64
|
+
assert_equal 'default.jpg', photo.title
|
|
65
|
+
assert_equal 'Testrrr', photo.slug
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_create_failure
|
|
70
|
+
assert_no_difference 'Gallery::Photo.count' do
|
|
71
|
+
post :create, :gallery_id => gallery_galleries(:default), :gallery_photo => { }
|
|
72
|
+
assert_response :success
|
|
73
|
+
assert_template 'new'
|
|
74
|
+
assert_equal 'Failed to create Photo', flash[:error]
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_create_multiple
|
|
80
|
+
Gallery::Photo.delete_all
|
|
81
|
+
|
|
82
|
+
assert_difference 'Gallery::Photo.count', 2 do
|
|
83
|
+
post :create, :gallery_id => gallery_galleries(:default), :gallery_photo => {
|
|
84
|
+
:title => 'Test Photo',
|
|
85
|
+
:slug => 'test-photo',
|
|
86
|
+
:image => [
|
|
87
|
+
fixture_file_upload('/files/default.jpg', 'image/jpeg'),
|
|
88
|
+
fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
assert_response :redirect
|
|
92
|
+
assert_redirected_to :action => :index
|
|
93
|
+
|
|
94
|
+
photo_a, photo_b = Gallery::Photo.all
|
|
95
|
+
|
|
96
|
+
assert_equal 'default.jpg', photo_a.image_file_name
|
|
97
|
+
assert_equal 'default.jpg', photo_b.image_file_name
|
|
98
|
+
assert_equal 'Test Photo 1', photo_a.title
|
|
99
|
+
assert_equal 'Test Photo 2', photo_b.title
|
|
100
|
+
assert_equal 'test-photo-1', photo_a.slug
|
|
101
|
+
assert_equal 'test-photo-2', photo_b.slug
|
|
102
|
+
assert_equal 'Photo created', flash[:notice]
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_get_edit
|
|
108
|
+
photo = gallery_photos(:default)
|
|
109
|
+
get :edit, :gallery_id => photo.gallery, :id => photo
|
|
110
|
+
assert_response :success
|
|
111
|
+
assert_template 'edit'
|
|
112
|
+
assert_select "form[action='/admin/gallery/galleries/#{photo.gallery.id}/photos/#{photo.id}']"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_get_edit_failure
|
|
116
|
+
get :edit, :gallery_id => gallery_galleries(:default), :id => 'invalid'
|
|
117
|
+
assert_response :redirect
|
|
118
|
+
assert_redirected_to :action => :index
|
|
119
|
+
assert_equal 'Photo not found', flash[:error]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def test_update
|
|
123
|
+
photo = gallery_photos(:default)
|
|
124
|
+
put :update, :gallery_id => photo.gallery, :id => photo, :gallery_photo => {
|
|
125
|
+
:title => 'Updated Title'
|
|
126
|
+
}
|
|
127
|
+
assert_response :redirect
|
|
128
|
+
assert_redirected_to :action => :index
|
|
129
|
+
assert_equal 'Photo updated', flash[:notice]
|
|
130
|
+
|
|
131
|
+
photo.reload
|
|
132
|
+
assert_equal 'Updated Title', photo.title
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_update_failure
|
|
136
|
+
photo = gallery_photos(:default)
|
|
137
|
+
put :update, :gallery_id => photo.gallery, :id => photo, :gallery_photo => {
|
|
138
|
+
:title => 'Updated Title',
|
|
139
|
+
:image => fixture_file_upload('/files/default.txt', 'text/plain')
|
|
140
|
+
}
|
|
141
|
+
assert_response :success
|
|
142
|
+
assert_template :edit
|
|
143
|
+
assert_equal 'Failed to updated Photo', flash[:error]
|
|
144
|
+
|
|
145
|
+
photo.reload
|
|
146
|
+
assert_not_equal 'Updated Title', photo.description
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_destroy
|
|
150
|
+
photo = gallery_photos(:default)
|
|
151
|
+
assert_difference 'Gallery::Photo.count', -1 do
|
|
152
|
+
delete :destroy, :gallery_id => photo.gallery, :id => photo
|
|
153
|
+
assert_response :redirect
|
|
154
|
+
assert_redirected_to :action => :index
|
|
155
|
+
assert_equal 'Photo deleted', flash[:notice]
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def test_reorder
|
|
160
|
+
gallery = gallery_galleries(:default)
|
|
161
|
+
photo_one = gallery_photos(:default)
|
|
162
|
+
photo_two = Gallery::Photo.create!(
|
|
163
|
+
:gallery => gallery,
|
|
164
|
+
:title => 'Test Photo',
|
|
165
|
+
:slug => 'test-photo',
|
|
166
|
+
:image => fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
|
167
|
+
)
|
|
168
|
+
assert_equal 0, photo_one.position
|
|
169
|
+
assert_equal 1, photo_two.position
|
|
170
|
+
|
|
171
|
+
post :reorder, :gallery_id => photo_one.gallery, :gallery_photo => [photo_two.id, photo_one.id]
|
|
172
|
+
assert_response :success
|
|
173
|
+
photo_one.reload
|
|
174
|
+
photo_two.reload
|
|
175
|
+
|
|
176
|
+
assert_equal 1, photo_one.position
|
|
177
|
+
assert_equal 0, photo_two.position
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def test_get_crop
|
|
181
|
+
photo = gallery_photos(:default)
|
|
182
|
+
photo.image = fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
|
183
|
+
photo.save!
|
|
184
|
+
|
|
185
|
+
get :crop, :gallery_id => photo.gallery, :id => photo
|
|
186
|
+
assert_response :success
|
|
187
|
+
assert_template 'crop'
|
|
188
|
+
assert assigns(:photo)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_crop_thumbnail
|
|
192
|
+
photo = gallery_photos(:default)
|
|
193
|
+
put :update, :gallery_id => photo.gallery, :id => photo, :photo => {
|
|
194
|
+
:thumb_crop_x => '0',
|
|
195
|
+
:thumb_crop_y => '0',
|
|
196
|
+
:thumb_crop_w => '100',
|
|
197
|
+
:thumb_crop_h => '100'
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
assert_response :redirect
|
|
201
|
+
assert_redirected_to :action => :index
|
|
202
|
+
assert_equal 'Photo updated', flash[:notice]
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_crop_thumbnail_and_full
|
|
207
|
+
gallery = Gallery::Gallery.create!(
|
|
208
|
+
:title => "Title",
|
|
209
|
+
:slug => "title",
|
|
210
|
+
:force_ratio_full => true
|
|
211
|
+
)
|
|
212
|
+
photo = Gallery::Photo.create!(
|
|
213
|
+
:gallery => gallery,
|
|
214
|
+
:title => 'Test Photo',
|
|
215
|
+
:slug => 'test-photo',
|
|
216
|
+
:image => fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
|
217
|
+
)
|
|
218
|
+
put :update, :gallery_id => gallery, :id => photo, :photo => {
|
|
219
|
+
:thumb_crop_x => '0',
|
|
220
|
+
:thumb_crop_y => '0',
|
|
221
|
+
:thumb_crop_w => '100',
|
|
222
|
+
:thumb_crop_h => '100',
|
|
223
|
+
:full_crop_x => '0',
|
|
224
|
+
:full_crop_y => '0',
|
|
225
|
+
:full_crop_w => '100',
|
|
226
|
+
:full_crop_h => '100'
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
assert_response :redirect
|
|
230
|
+
assert_redirected_to :action => :index
|
|
231
|
+
assert_equal 'Photo updated', flash[:notice]
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class Gallery::GalleriesControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def test_get_index
|
|
6
|
+
get :index
|
|
7
|
+
assert_response :success
|
|
8
|
+
assert_template :index
|
|
9
|
+
assert assigns(:galleries)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_get_show
|
|
13
|
+
get :show, :id => gallery_galleries(:default)
|
|
14
|
+
assert_response :success
|
|
15
|
+
assert_template :show
|
|
16
|
+
assert assigns(:gallery)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_get_show_failure
|
|
20
|
+
get :show, :id => 'invalid'
|
|
21
|
+
assert_response 404
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
fixtures :all
|
|
8
|
+
include ActionDispatch::TestProcess
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
reset_config
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# resetting default configuration
|
|
15
|
+
def reset_config
|
|
16
|
+
ComfyGallery.configure do |config|
|
|
17
|
+
config.admin_route_prefix = 'admin'
|
|
18
|
+
config.upload_options = { }
|
|
19
|
+
config.admin_controller = 'ApplicationController'
|
|
20
|
+
config.form_builder = 'ComfyGallery::FormBuilder'
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Example usage:
|
|
25
|
+
# assert_has_errors_on( @record, [:field_1, :field_2] )
|
|
26
|
+
# assert_has_errors_on( @record, {:field_1 => 'Message1', :field_2 => 'Message 2'} )
|
|
27
|
+
def assert_has_errors_on(record, fields)
|
|
28
|
+
fields = [fields].flatten unless fields.is_a?(Hash)
|
|
29
|
+
fields.each do |field, message|
|
|
30
|
+
assert record.errors.to_hash.has_key?(field.to_sym), "#{record.class.name} should error on invalid #{field}"
|
|
31
|
+
if message && record.errors[field].is_a?(Array) && !message.is_a?(Array)
|
|
32
|
+
assert_not_nil record.errors[field].index(message)
|
|
33
|
+
elsif message
|
|
34
|
+
assert_equal message, record.errors[field]
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class ConfigurationTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def test_configuration_presense
|
|
6
|
+
assert config = ComfyGallery.configuration
|
|
7
|
+
assert_equal ({}), config.upload_options
|
|
8
|
+
assert_equal 'admin', config.admin_route_prefix
|
|
9
|
+
assert_equal 'ApplicationController', config.admin_controller
|
|
10
|
+
assert_equal 'ComfyGallery::FormBuilder', config.form_builder
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_initialization_overrides
|
|
14
|
+
ComfyGallery.configuration.admin_route_prefix = 'admin'
|
|
15
|
+
assert_equal 'admin', ComfyGallery.configuration.admin_route_prefix
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class GalleryTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def test_fixtures_validity
|
|
6
|
+
Gallery::Gallery.all.each do |gallery|
|
|
7
|
+
assert gallery.valid?, gallery.errors.full_messages.to_s
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_validations
|
|
12
|
+
gallery = Gallery::Gallery.new
|
|
13
|
+
assert gallery.invalid?
|
|
14
|
+
assert_has_errors_on gallery, [:title, :slug]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_creation
|
|
18
|
+
assert_difference 'Gallery::Gallery.count' do
|
|
19
|
+
Gallery::Gallery.create!(
|
|
20
|
+
:title => 'Test Gallery',
|
|
21
|
+
:slug => 'test-gallery'
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_destoy
|
|
27
|
+
gallery = gallery_galleries(:default)
|
|
28
|
+
assert_difference ['Gallery::Gallery.count', 'Gallery::Photo.count'], -1 do
|
|
29
|
+
gallery.destroy
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class PhotoTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def test_fixtures_validity
|
|
6
|
+
Gallery::Photo.all.each do |photo|
|
|
7
|
+
assert photo.valid?, photo.errors.full_messages.to_s
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_validations
|
|
12
|
+
photo = Gallery::Photo.new
|
|
13
|
+
assert photo.invalid?
|
|
14
|
+
assert_has_errors_on photo, {
|
|
15
|
+
:gallery_id => ["can't be blank"],
|
|
16
|
+
:slug => ["can't be blank", "is invalid"],
|
|
17
|
+
:image_file_name => ["There was no file uploaded!"]
|
|
18
|
+
}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_creation
|
|
22
|
+
gallery = gallery_galleries(:default)
|
|
23
|
+
assert_difference 'Gallery::Photo.count' do
|
|
24
|
+
Gallery::Photo.create!(
|
|
25
|
+
:gallery => gallery,
|
|
26
|
+
:title => 'Test Photo',
|
|
27
|
+
:slug => 'test-photo',
|
|
28
|
+
:image => fixture_file_upload('/files/default.jpg', 'image/jpeg')
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: comfy_gallery
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Oleg Khabarov
|
|
9
|
+
- Stephen McLeod
|
|
10
|
+
- The Working Group Inc.
|
|
11
|
+
autorequire:
|
|
12
|
+
bindir: bin
|
|
13
|
+
cert_chain: []
|
|
14
|
+
date: 2012-01-20 00:00:00.000000000Z
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: rails
|
|
18
|
+
requirement: &70118917214260 !ruby/object:Gem::Requirement
|
|
19
|
+
none: false
|
|
20
|
+
requirements:
|
|
21
|
+
- - ! '>='
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 3.1.0
|
|
24
|
+
type: :runtime
|
|
25
|
+
prerelease: false
|
|
26
|
+
version_requirements: *70118917214260
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: paperclip
|
|
29
|
+
requirement: &70118917211280 !ruby/object:Gem::Requirement
|
|
30
|
+
none: false
|
|
31
|
+
requirements:
|
|
32
|
+
- - ! '>='
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: 2.3.0
|
|
35
|
+
type: :runtime
|
|
36
|
+
prerelease: false
|
|
37
|
+
version_requirements: *70118917211280
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: jquery-rails
|
|
40
|
+
requirement: &70118917203280 !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 1.0.14
|
|
46
|
+
type: :runtime
|
|
47
|
+
prerelease: false
|
|
48
|
+
version_requirements: *70118917203280
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: sqlite3
|
|
51
|
+
requirement: &70118917201060 !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ! '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
type: :development
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: *70118917201060
|
|
60
|
+
- !ruby/object:Gem::Dependency
|
|
61
|
+
name: jeweler
|
|
62
|
+
requirement: &70118917198640 !ruby/object:Gem::Requirement
|
|
63
|
+
none: false
|
|
64
|
+
requirements:
|
|
65
|
+
- - ! '>='
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
type: :development
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: *70118917198640
|
|
71
|
+
description: ''
|
|
72
|
+
email: oleg@twg.ca
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files:
|
|
76
|
+
- LICENSE
|
|
77
|
+
- README.md
|
|
78
|
+
files:
|
|
79
|
+
- .document
|
|
80
|
+
- .travis.yml
|
|
81
|
+
- Gemfile
|
|
82
|
+
- LICENSE
|
|
83
|
+
- README.md
|
|
84
|
+
- Rakefile
|
|
85
|
+
- VERSION
|
|
86
|
+
- app/assets/images/sofa_gallery/jcrop.gif
|
|
87
|
+
- app/assets/images/sofa_gallery/orbit/bullets.jpg
|
|
88
|
+
- app/assets/images/sofa_gallery/orbit/left-arrow.png
|
|
89
|
+
- app/assets/images/sofa_gallery/orbit/loading.gif
|
|
90
|
+
- app/assets/images/sofa_gallery/orbit/mask-black.png
|
|
91
|
+
- app/assets/images/sofa_gallery/orbit/pause-black.png
|
|
92
|
+
- app/assets/images/sofa_gallery/orbit/right-arrow.png
|
|
93
|
+
- app/assets/images/sofa_gallery/orbit/rotator-black.png
|
|
94
|
+
- app/assets/images/sofa_gallery/orbit/timer-black.png
|
|
95
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnNext.png
|
|
96
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/btnPrevious.png
|
|
97
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/contentPattern.png
|
|
98
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/default_thumbnail.gif
|
|
99
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/loader.gif
|
|
100
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_rounded/sprite.png
|
|
101
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnNext.png
|
|
102
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/btnPrevious.png
|
|
103
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/contentPattern.png
|
|
104
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/default_thumbnail.gif
|
|
105
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/loader.gif
|
|
106
|
+
- app/assets/images/sofa_gallery/prettyPhoto/dark_square/sprite.png
|
|
107
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/default_thumb.png
|
|
108
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/loader.gif
|
|
109
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/sprite.png
|
|
110
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/sprite_next.png
|
|
111
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/sprite_prev.png
|
|
112
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/sprite_x.png
|
|
113
|
+
- app/assets/images/sofa_gallery/prettyPhoto/default/sprite_y.png
|
|
114
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/btnNext.png
|
|
115
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/btnPrevious.png
|
|
116
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternBottom.png
|
|
117
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternLeft.png
|
|
118
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternRight.png
|
|
119
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/contentPatternTop.png
|
|
120
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/default_thumbnail.gif
|
|
121
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/loader.gif
|
|
122
|
+
- app/assets/images/sofa_gallery/prettyPhoto/facebook/sprite.png
|
|
123
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnNext.png
|
|
124
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_rounded/btnPrevious.png
|
|
125
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_rounded/default_thumbnail.gif
|
|
126
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_rounded/loader.gif
|
|
127
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_rounded/sprite.png
|
|
128
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_square/btnNext.png
|
|
129
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_square/btnPrevious.png
|
|
130
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_square/default_thumbnail.gif
|
|
131
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_square/loader.gif
|
|
132
|
+
- app/assets/images/sofa_gallery/prettyPhoto/light_square/sprite.png
|
|
133
|
+
- app/assets/javascripts/sofa_gallery/admin.js
|
|
134
|
+
- app/assets/javascripts/sofa_gallery/application.js
|
|
135
|
+
- app/assets/javascripts/sofa_gallery/jquery.jcrop.js
|
|
136
|
+
- app/assets/javascripts/sofa_gallery/jquery.orbit-1.2.3.min.js
|
|
137
|
+
- app/assets/javascripts/sofa_gallery/thumbnails.js
|
|
138
|
+
- app/assets/stylesheets/comfy_gallery/admin.css
|
|
139
|
+
- app/assets/stylesheets/comfy_gallery/application.css
|
|
140
|
+
- app/assets/stylesheets/comfy_gallery/carousel.css.erb
|
|
141
|
+
- app/assets/stylesheets/comfy_gallery/gallery_list.css
|
|
142
|
+
- app/assets/stylesheets/comfy_gallery/jquery.jcrop.css
|
|
143
|
+
- app/assets/stylesheets/comfy_gallery/reset.css
|
|
144
|
+
- app/assets/stylesheets/comfy_gallery/thumbnails.css.erb
|
|
145
|
+
- app/controllers/admin/gallery/base_controller.rb
|
|
146
|
+
- app/controllers/admin/gallery/galleries_controller.rb
|
|
147
|
+
- app/controllers/admin/gallery/photos_controller.rb
|
|
148
|
+
- app/controllers/application_controller.rb
|
|
149
|
+
- app/controllers/gallery/galleries_controller.rb
|
|
150
|
+
- app/helpers/gallery/application_helper.rb
|
|
151
|
+
- app/models/gallery/gallery.rb
|
|
152
|
+
- app/models/gallery/photo.rb
|
|
153
|
+
- app/views/admin/gallery/_html_head.html.erb
|
|
154
|
+
- app/views/admin/gallery/_navigation.html.erb
|
|
155
|
+
- app/views/admin/gallery/galleries/_form.html.erb
|
|
156
|
+
- app/views/admin/gallery/galleries/edit.html.erb
|
|
157
|
+
- app/views/admin/gallery/galleries/index.html.erb
|
|
158
|
+
- app/views/admin/gallery/galleries/new.html.erb
|
|
159
|
+
- app/views/admin/gallery/photos/_form.html.erb
|
|
160
|
+
- app/views/admin/gallery/photos/crop.html.erb
|
|
161
|
+
- app/views/admin/gallery/photos/edit.html.erb
|
|
162
|
+
- app/views/admin/gallery/photos/index.html.erb
|
|
163
|
+
- app/views/admin/gallery/photos/new.html.erb
|
|
164
|
+
- app/views/gallery/_carousel.html.erb
|
|
165
|
+
- app/views/gallery/_list_galleries.html.erb
|
|
166
|
+
- app/views/gallery/_thumbnails.html.erb
|
|
167
|
+
- app/views/gallery/galleries/index.html.erb
|
|
168
|
+
- app/views/gallery/galleries/show.html.erb
|
|
169
|
+
- app/views/layouts/gallery/application.html.erb
|
|
170
|
+
- comfy_gallery.gemspec
|
|
171
|
+
- config.ru
|
|
172
|
+
- config/application.rb
|
|
173
|
+
- config/boot.rb
|
|
174
|
+
- config/database.yml
|
|
175
|
+
- config/environment.rb
|
|
176
|
+
- config/environments/development.rb
|
|
177
|
+
- config/environments/production.rb
|
|
178
|
+
- config/environments/test.rb
|
|
179
|
+
- config/initializers/comfy_gallery.rb
|
|
180
|
+
- config/initializers/paperclip.rb
|
|
181
|
+
- config/routes.rb
|
|
182
|
+
- db/migrate/01_create_comfy_gallery.rb
|
|
183
|
+
- lib/comfy_gallery.rb
|
|
184
|
+
- lib/comfy_gallery/configuration.rb
|
|
185
|
+
- lib/comfy_gallery/engine.rb
|
|
186
|
+
- lib/comfy_gallery/form_builder.rb
|
|
187
|
+
- lib/generators/README
|
|
188
|
+
- lib/generators/comfy_gallery_generator.rb
|
|
189
|
+
- lib/paperclip_processors/cropper.rb
|
|
190
|
+
- lib/tasks/comfy_gallery.rake
|
|
191
|
+
- script/rails
|
|
192
|
+
- sofa_gallery.gemspec
|
|
193
|
+
- test/fixtures/files/default.jpg
|
|
194
|
+
- test/fixtures/files/default.txt
|
|
195
|
+
- test/fixtures/files/default2.jpg
|
|
196
|
+
- test/fixtures/gallery/galleries.yml
|
|
197
|
+
- test/fixtures/gallery/photos.yml
|
|
198
|
+
- test/functional/admin/gallery/galleries_controller_test.rb
|
|
199
|
+
- test/functional/admin/gallery/photos_controller_test.rb
|
|
200
|
+
- test/functional/gallery/galleries_controller_test.rb
|
|
201
|
+
- test/test_helper.rb
|
|
202
|
+
- test/unit/configuration_test.rb
|
|
203
|
+
- test/unit/gallery_test.rb
|
|
204
|
+
- test/unit/photo_test.rb
|
|
205
|
+
homepage: http://github.com/comfy/comfy-gallery
|
|
206
|
+
licenses:
|
|
207
|
+
- MIT
|
|
208
|
+
post_install_message:
|
|
209
|
+
rdoc_options: []
|
|
210
|
+
require_paths:
|
|
211
|
+
- lib
|
|
212
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
|
+
none: false
|
|
214
|
+
requirements:
|
|
215
|
+
- - ! '>='
|
|
216
|
+
- !ruby/object:Gem::Version
|
|
217
|
+
version: '0'
|
|
218
|
+
segments:
|
|
219
|
+
- 0
|
|
220
|
+
hash: 3493133440130363197
|
|
221
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
|
+
none: false
|
|
223
|
+
requirements:
|
|
224
|
+
- - ! '>='
|
|
225
|
+
- !ruby/object:Gem::Version
|
|
226
|
+
version: '0'
|
|
227
|
+
requirements: []
|
|
228
|
+
rubyforge_project:
|
|
229
|
+
rubygems_version: 1.8.10
|
|
230
|
+
signing_key:
|
|
231
|
+
specification_version: 3
|
|
232
|
+
summary: ComfyGallery is an image gallery engine for Rails 3.1 apps (and ComfortableMexicanSofa)
|
|
233
|
+
test_files: []
|