radiant-images-extension 0.3.3 → 0.3.4
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/README.md +60 -23
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/app/controllers/admin/images_controller.rb +5 -19
- data/app/models/image.rb +15 -60
- data/app/views/admin/images/_bottom.haml +1 -6
- data/config/routes.rb +1 -1
- data/images_extension.rb +8 -12
- data/lib/images/interface/admin/images.rb +1 -2
- data/lib/images/tags/core.rb +16 -223
- data/public/stylesheets/sass/admin/extensions/images/index.sass +4 -0
- data/radiant-images-extension.gemspec +9 -7
- data/spec/controllers/admin/images_controller_spec.rb +88 -31
- data/spec/datasets/images.rb +1 -1
- data/spec/datasets/squaretalent.png +0 -0
- data/spec/lib/images/tags/core_spec.rb +190 -72
- data/spec/models/image_spec.rb +25 -20
- metadata +33 -19
- data/CHANGELOG +0 -9
- data/public/javascripts/admin/extensions/images/edit.js +0 -0
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-images-extension}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["squaretalent"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-02}
|
13
13
|
s.description = %q{Image Radiant Extension management tool, meant only to be useful to pages and extensions that need to require images.}
|
14
14
|
s.email = %q{info@squaretalent.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".gitignore",
|
21
|
-
"CHANGELOG",
|
22
21
|
"LICENSE",
|
23
22
|
"README.md",
|
24
23
|
"Rakefile",
|
@@ -51,12 +50,12 @@ Gem::Specification.new do |s|
|
|
51
50
|
"public/images/extensions/images/missing_icon.png",
|
52
51
|
"public/images/extensions/images/missing_normal.png",
|
53
52
|
"public/images/extensions/images/missing_preview.png",
|
54
|
-
"public/javascripts/admin/extensions/images/edit.js",
|
55
53
|
"public/stylesheets/sass/admin/extensions/images/edit.sass",
|
56
54
|
"public/stylesheets/sass/admin/extensions/images/index.sass",
|
57
55
|
"radiant-images-extension.gemspec",
|
58
56
|
"spec/controllers/admin/images_controller_spec.rb",
|
59
57
|
"spec/datasets/images.rb",
|
58
|
+
"spec/datasets/squaretalent.png",
|
60
59
|
"spec/lib/images/tags/core_spec.rb",
|
61
60
|
"spec/models/image_spec.rb",
|
62
61
|
"spec/spec.opts",
|
@@ -80,20 +79,23 @@ Gem::Specification.new do |s|
|
|
80
79
|
s.specification_version = 3
|
81
80
|
|
82
81
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
83
|
-
s.add_runtime_dependency(%q<
|
82
|
+
s.add_runtime_dependency(%q<radiant>, [">= 0.9.1"])
|
83
|
+
s.add_runtime_dependency(%q<paperclip>, ["~> 2.3.5"])
|
84
84
|
s.add_runtime_dependency(%q<aws-s3>, [">= 0.6.2"])
|
85
85
|
s.add_runtime_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
86
86
|
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
87
87
|
s.add_development_dependency(%q<rr>, [">= 1.0.0"])
|
88
88
|
else
|
89
|
-
s.add_dependency(%q<
|
89
|
+
s.add_dependency(%q<radiant>, [">= 0.9.1"])
|
90
|
+
s.add_dependency(%q<paperclip>, ["~> 2.3.5"])
|
90
91
|
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
91
92
|
s.add_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
92
93
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
93
94
|
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
94
95
|
end
|
95
96
|
else
|
96
|
-
s.add_dependency(%q<
|
97
|
+
s.add_dependency(%q<radiant>, [">= 0.9.1"])
|
98
|
+
s.add_dependency(%q<paperclip>, ["~> 2.3.5"])
|
97
99
|
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
98
100
|
s.add_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
99
101
|
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Admin::ImagesController do
|
4
|
+
|
4
5
|
dataset :users
|
5
6
|
dataset :images
|
6
7
|
|
@@ -8,64 +9,120 @@ describe Admin::ImagesController do
|
|
8
9
|
@image = images(:first)
|
9
10
|
@images = Image.all
|
10
11
|
end
|
11
|
-
|
12
|
-
context '
|
12
|
+
|
13
|
+
context 'index action' do
|
14
|
+
|
15
|
+
context 'user not logged in' do
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
it 'should redirect to login path' do
|
18
|
+
get :index
|
19
|
+
response.should redirect_to login_path
|
20
|
+
end
|
18
21
|
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'user logged in' do
|
22
|
-
before :each do
|
23
|
-
login_as :admin
|
24
|
-
stub(AWS::S3::Base).establish_connection!
|
25
22
|
end
|
26
23
|
|
27
|
-
context '
|
28
|
-
|
24
|
+
context 'user logged in' do
|
25
|
+
|
26
|
+
before :each do
|
27
|
+
login_as :admin
|
28
|
+
stub(AWS::S3::Base).establish_connection!
|
29
|
+
end
|
30
|
+
|
29
31
|
it 'should render the index template on index action' do
|
30
32
|
get :index
|
31
33
|
response.should render_template(:index)
|
32
34
|
end
|
33
|
-
|
35
|
+
|
34
36
|
it 'should have a list of images' do
|
35
37
|
get :index
|
36
38
|
assigns(:images).should == @images
|
37
39
|
end
|
38
|
-
|
40
|
+
|
39
41
|
it 'should use pagination' do
|
40
42
|
get :index
|
41
43
|
assigns(:images).class.should == WillPaginate::Collection
|
42
44
|
end
|
45
|
+
|
46
|
+
it 'should include the index stylesheet' do
|
47
|
+
mock(controller).index_assets
|
48
|
+
get :index
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'edit action' do
|
56
|
+
|
57
|
+
context 'user logged in' do
|
58
|
+
|
59
|
+
before :each do
|
60
|
+
login_as :admin
|
61
|
+
stub(AWS::S3::Base).establish_connection!
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should include the edit stylesheet' do
|
65
|
+
mock(controller).edit_assets
|
66
|
+
get :edit, :id => @image.id
|
67
|
+
end
|
43
68
|
|
44
69
|
end
|
45
70
|
|
46
|
-
|
47
|
-
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'show action' do
|
74
|
+
|
75
|
+
context 'user logged in' do
|
76
|
+
|
48
77
|
before :each do
|
49
78
|
login_as :admin
|
50
79
|
stub(AWS::S3::Base).establish_connection!
|
51
80
|
end
|
52
81
|
|
53
|
-
it 'should
|
54
|
-
|
55
|
-
|
82
|
+
it 'should include the edit stylesheet' do
|
83
|
+
mock(controller).edit_assets
|
84
|
+
get :show, :id => @image.id
|
56
85
|
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
context 'rescusing S3 exceptions' do
|
92
|
+
|
93
|
+
before :each do
|
94
|
+
controller = Admin::ImagesController.new
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should catch any AWS S3 response errors thrown' do
|
98
|
+
stub(controller).redirect_to(anything)
|
99
|
+
controller.send :rescue_s3_exceptions do
|
100
|
+
raise AWS::S3::ResponseError.new('error name', '')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should set the flash message' do
|
105
|
+
stub(controller).redirect_to(anything)
|
106
|
+
controller.send :rescue_s3_exceptions do
|
107
|
+
raise AWS::S3::ResponseError.new('some error' ,'')
|
108
|
+
end
|
109
|
+
(controller.send :flash)[:error].should == 'some error'
|
57
110
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should redirect to the admin images url' do
|
114
|
+
mock(controller).redirect_to(admin_images_url)
|
115
|
+
controller.send :rescue_s3_exceptions do
|
116
|
+
raise AWS::S3::ResponseError.new('error' ,'')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should not catch any other errors thrown' do
|
121
|
+
lambda { controller.send :rescue_s3_exceptions do
|
122
|
+
raise 'another type of error'
|
123
|
+
end }.should raise_error 'another type of error'
|
66
124
|
end
|
67
125
|
|
68
126
|
end
|
69
127
|
|
70
|
-
|
71
|
-
end
|
128
|
+
end
|
data/spec/datasets/images.rb
CHANGED
Binary file
|
@@ -1,22 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Images::Tags::Core do
|
4
|
-
dataset :pages, :images
|
5
|
-
|
6
|
-
it 'should describe these tags' do
|
7
|
-
Images::Tags::Core.tags.sort.should == [
|
8
|
-
'images',
|
9
|
-
'images:if_images',
|
10
|
-
'images:unless_images',
|
11
|
-
'images:each',
|
12
|
-
'image',
|
13
|
-
'image:url',
|
14
|
-
'image:id',
|
15
|
-
'image:title'].sort
|
16
|
-
end
|
17
4
|
|
5
|
+
dataset :pages, :images
|
6
|
+
|
18
7
|
before(:all) do
|
19
|
-
@images = [ images(:first), images(:second)
|
8
|
+
@images = [ images(:first), images(:second), images(:third),
|
9
|
+
images(:fourth), images(:fifth), images(:sixth) ]
|
20
10
|
end
|
21
11
|
|
22
12
|
before(:each) do
|
@@ -25,81 +15,209 @@ describe Images::Tags::Core do
|
|
25
15
|
|
26
16
|
describe '<r:images>' do
|
27
17
|
|
28
|
-
it 'should render' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
18
|
+
it 'should render its contents' do
|
19
|
+
input = '<r:images>success</r:images>'
|
20
|
+
expected = 'success'
|
21
|
+
pages(:home).should render(input).as(expected)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should add the images namespace to nested radius tags' do
|
25
|
+
input = '<r:images><r:if_images>success</r:if_images></r:images>'
|
26
|
+
pages(:home).should render(input)
|
33
27
|
end
|
34
28
|
|
35
29
|
end
|
36
30
|
|
37
31
|
describe '<r:images:if_images>' do
|
38
32
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
33
|
+
it 'should render its contents when there are images' do
|
34
|
+
input = '<r:images><r:if_images>success</r:if_images></r:images>'
|
35
|
+
expected = 'success'
|
36
|
+
pages(:home).should render(input).as(expected)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should not render its contents when there are no images' do
|
40
|
+
mock(Image).all { [] }
|
41
|
+
input = '<r:images><r:if_images>failure</r:if_images></r:images>'
|
42
|
+
expected = ''
|
43
|
+
pages(:home).should render(input).as(expected)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '<r:images:unless_images>' do
|
49
|
+
|
50
|
+
it 'should render its contents when there are no images' do
|
51
|
+
mock(Image).all { [] }
|
52
|
+
input = '<r:images><r:unless_images>success</r:unless_images></r:images>'
|
53
|
+
expected = 'success'
|
54
|
+
pages(:home).should render(input).as(expected)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should not render its contents when there are images' do
|
58
|
+
input = '<r:images><r:unless_images>failure</r:unless_images></r:images>'
|
59
|
+
expected = ''
|
60
|
+
pages(:home).should render(input).as(expected)
|
52
61
|
end
|
53
62
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '<r:images:each>' do
|
66
|
+
|
67
|
+
it 'should expand its contents once for each of the available images' do
|
68
|
+
input = '<r:images:each>test </r:images:each>'
|
69
|
+
expected = 'test test test test test test '
|
70
|
+
pages(:home).should render(input).as(expected)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should not expand its contents if there are no images available' do
|
74
|
+
mock(Image).all { [] }
|
75
|
+
input = '<r:images:each>test </r:images:each>'
|
76
|
+
expected = ''
|
77
|
+
pages(:home).should render(input).as(expected)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should limit the number of images based on the limit parameter passed' do
|
81
|
+
input = '<r:images:each limit="3"><r:image:title /> </r:images:each>'
|
82
|
+
expected = 'first second third '
|
83
|
+
pages(:home).should render(input).as(expected)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should use the offset parameter to ignore results before the offset' do
|
87
|
+
input = '<r:images:each limit="3" offset="2"><r:image:title /> </r:images:each>'
|
88
|
+
expected = 'third fourth fifth '
|
89
|
+
pages(:home).should render(input).as(expected)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should order the results based by the key passed' do
|
93
|
+
input = '<r:images:each by="title"><r:image:title /> </r:images:each>'
|
94
|
+
expected = 'third fifth first fourth second sixth '
|
95
|
+
pages(:home).should render(input).as(expected)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should order the results by ascending order when asc is passed for the order' do
|
99
|
+
input = '<r:images:each by="id" order="asc" ><r:image:title /> </r:images:each>'
|
100
|
+
expected = 'first second third fourth fifth sixth '
|
101
|
+
pages(:home).should render(input).as(expected)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should order the results by descending order when desc is passed for the order' do
|
105
|
+
input = '<r:images:each by="id" order="desc" ><r:image:title /> </r:images:each>'
|
106
|
+
expected = 'sixth fifth fourth third second first '
|
107
|
+
pages(:home).should render(input).as(expected)
|
68
108
|
end
|
69
109
|
|
70
110
|
end
|
71
111
|
|
72
|
-
describe '<r:
|
112
|
+
describe '<r:image>' do
|
73
113
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
exp = 'success'
|
79
|
-
|
80
|
-
pages(:home).should render(tag).as(exp)
|
81
|
-
end
|
82
|
-
it 'should render' do
|
83
|
-
tag = '<r:images key="title" value="notme"><r:unless_images>success</r:unless_images></r:images>'
|
84
|
-
exp = 'success'
|
85
|
-
|
86
|
-
pages(:home).should render(tag).as(exp)
|
87
|
-
end
|
114
|
+
it 'should add the image namespace to nested radius tags' do
|
115
|
+
input = '<r:image title="first"><r:title /></r:image>'
|
116
|
+
expected = 'first'
|
117
|
+
pages(:home).should render(input).as(expected)
|
88
118
|
end
|
89
119
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
120
|
+
it 'should render its contents if there is a current image' do
|
121
|
+
input = '<r:images:each><r:image title="first"><r:title /> </r:image></r:images:each>'
|
122
|
+
expected = 'first second third fourth fifth sixth '
|
123
|
+
pages(:home).should render(input).as(expected)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should not render its contents if there is no current image' do
|
127
|
+
input = '<r:image title="invalid"><r:title /></r:image>'
|
128
|
+
expected = ''
|
129
|
+
pages(:home).should render(input).as(expected)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'should allow images to be looked up by their id attribute' do
|
133
|
+
mock(Image).find('5') { @images[4] }
|
134
|
+
input = '<r:image id="5"><r:title /></r:image>'
|
135
|
+
expected = 'fifth'
|
136
|
+
pages(:home).should render(input).as(expected)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should allow images to be looked up by their position attribute' do
|
140
|
+
input = '<r:image position="3"><r:title /></r:image>'
|
141
|
+
expected = 'third'
|
142
|
+
pages(:home).should render(input).as(expected)
|
143
|
+
end
|
94
144
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
145
|
+
it 'should allow images to be looked up by their title attribute' do
|
146
|
+
input = '<r:image title="sixth"><r:title /></r:image>'
|
147
|
+
expected = 'sixth'
|
148
|
+
pages(:home).should render(input).as(expected)
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '<r:image:url>' do
|
154
|
+
|
155
|
+
it 'should render a valid url given a valid image context'
|
100
156
|
|
101
|
-
|
102
|
-
|
157
|
+
it 'should not render a valid url if there is no current image'
|
158
|
+
|
159
|
+
it 'should render the url with the default style if not specified'
|
160
|
+
|
161
|
+
it 'should render the url with the style specified by the user'
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
describe '<r:image:tag>' do
|
166
|
+
|
167
|
+
it 'should render a valid img tag given a valid image context'
|
168
|
+
|
169
|
+
it 'should not render a valid img tag if there is no current image'
|
170
|
+
|
171
|
+
it 'should render the img tag with the default style if not specified'
|
172
|
+
|
173
|
+
it 'should render the img tag with the style specified by the user'
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
describe '<r:image:id>' do
|
178
|
+
|
179
|
+
it 'should render the id of the current image context' do
|
180
|
+
input = '<r:image title="sixth"><r:id /></r:image>'
|
181
|
+
expected = @images[5].id.to_s
|
182
|
+
pages(:home).should render(input).as(expected)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should not render anything if there is no current image context' do
|
186
|
+
input = '<r:image title="invalid"><r:id /></r:image>'
|
187
|
+
expected = ''
|
188
|
+
pages(:home).should render(input).as(expected)
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '<r:image:title>' do
|
194
|
+
|
195
|
+
it 'should render the title of the current image context' do
|
196
|
+
input = '<r:image title="fourth"><r:title /></r:image>'
|
197
|
+
expected = 'fourth'
|
198
|
+
pages(:home).should render(input).as(expected)
|
199
|
+
end
|
200
|
+
|
201
|
+
it 'should not render anything if there is no current image context' do
|
202
|
+
input = '<r:image title="invalid"><r:title /></r:image>'
|
203
|
+
expected = ''
|
204
|
+
pages(:home).should render(input).as(expected)
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
describe '<r:image:position>' do
|
210
|
+
|
211
|
+
it 'should render the position of the current image context' do
|
212
|
+
input = '<r:image title="first"><r:position /></r:image>'
|
213
|
+
expected = '1'
|
214
|
+
pages(:home).should render(input).as(expected)
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should not render anything if there is no current image context' do
|
218
|
+
input = '<r:image title="invalid"><r:position /></r:image>'
|
219
|
+
expected = ''
|
220
|
+
pages(:home).should render(input).as(expected)
|
103
221
|
end
|
104
222
|
|
105
223
|
end
|