radiant-images-extension 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/.gitignore +1 -0
- data/LICENSE +19 -0
- data/README.md +41 -0
- data/Rakefile +141 -0
- data/VERSION +1 -0
- data/app/controllers/admin/images_controller.rb +50 -0
- data/app/models/image.rb +91 -0
- data/app/views/admin/images/_bottom.haml +13 -0
- data/app/views/admin/images/_fields.haml +22 -0
- data/app/views/admin/images/_fields_bottom.haml +10 -0
- data/app/views/admin/images/_fields_top.haml +7 -0
- data/app/views/admin/images/_image.haml +12 -0
- data/app/views/admin/images/edit.haml +14 -0
- data/app/views/admin/images/index.haml +16 -0
- data/app/views/admin/images/new.haml +12 -0
- data/app/views/admin/images/remove.haml +12 -0
- data/config/locales/en.yml +8 -0
- data/config/routes.rb +7 -0
- data/cucumber.yml +1 -0
- data/db/migrate/20100601042237_create_images.rb +22 -0
- data/db/migrate/20100602044124_add_position_to_images.rb +13 -0
- data/features/support/env.rb +16 -0
- data/features/support/paths.rb +14 -0
- data/images_extension.rb +53 -0
- data/lib/images/interface/admin/images.rb +37 -0
- data/lib/images/tags/image.rb +171 -0
- data/lib/tasks/images_extension_tasks.rake +77 -0
- data/public/images/extensions/images/missing_icon.png +0 -0
- data/public/images/extensions/images/missing_normal.png +0 -0
- data/public/images/extensions/images/missing_preview.png +0 -0
- data/public/javascripts/admin/extensions/images/edit.js +0 -0
- data/public/stylesheets/sass/admin/extensions/images/edit.sass +8 -0
- data/public/stylesheets/sass/admin/extensions/images/index.sass +103 -0
- data/radiant-images-extension.gemspec +99 -0
- data/spec/controllers/admin/images_controller_spec.rb +135 -0
- data/spec/datasets/images.rb +15 -0
- data/spec/lib/images/tags/image_spec.rb +240 -0
- data/spec/models/image_spec.rb +65 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +22 -0
- metadata +191 -0
Binary file
|
Binary file
|
Binary file
|
File without changes
|
@@ -0,0 +1,103 @@
|
|
1
|
+
#images_map
|
2
|
+
|
3
|
+
#images_headings
|
4
|
+
:background
|
5
|
+
:color #9e9e9e
|
6
|
+
:padding
|
7
|
+
:top 2px
|
8
|
+
:bottom 2px
|
9
|
+
|
10
|
+
h2
|
11
|
+
:font
|
12
|
+
:size 12px
|
13
|
+
:weight normal
|
14
|
+
:display inline
|
15
|
+
:color #ffffff
|
16
|
+
:text
|
17
|
+
:shadow #666 1px 1px 0px
|
18
|
+
|
19
|
+
h2.images
|
20
|
+
:padding
|
21
|
+
:left 9px
|
22
|
+
|
23
|
+
h2.modify
|
24
|
+
:float right
|
25
|
+
:width 100px
|
26
|
+
:padding
|
27
|
+
:right 4px
|
28
|
+
|
29
|
+
|
30
|
+
#images
|
31
|
+
|
32
|
+
.image
|
33
|
+
:border
|
34
|
+
:bottom 1px solid #F0F0F0
|
35
|
+
|
36
|
+
.attributes
|
37
|
+
:overflow hidden
|
38
|
+
:padding 0
|
39
|
+
|
40
|
+
&:hover
|
41
|
+
:background
|
42
|
+
:color #e0f0ff
|
43
|
+
|
44
|
+
.attribute
|
45
|
+
:float left
|
46
|
+
:height 40px
|
47
|
+
:padding
|
48
|
+
:right 4px
|
49
|
+
:left 9px
|
50
|
+
:line
|
51
|
+
:height 40px
|
52
|
+
|
53
|
+
&.image
|
54
|
+
:margin
|
55
|
+
:right 5px
|
56
|
+
|
57
|
+
.icon
|
58
|
+
:height 30px
|
59
|
+
:width 30px
|
60
|
+
:margin
|
61
|
+
:top -4px
|
62
|
+
|
63
|
+
&.title
|
64
|
+
|
65
|
+
a
|
66
|
+
:color #000000
|
67
|
+
:font
|
68
|
+
:weight bold
|
69
|
+
:size 16px
|
70
|
+
:text
|
71
|
+
:decoration none
|
72
|
+
|
73
|
+
&:hover
|
74
|
+
:color #0066ce
|
75
|
+
:text
|
76
|
+
:decoration underline
|
77
|
+
|
78
|
+
&.modify
|
79
|
+
:float right
|
80
|
+
:width 100px
|
81
|
+
:font
|
82
|
+
:size 10px
|
83
|
+
|
84
|
+
a
|
85
|
+
:color #000000
|
86
|
+
:text
|
87
|
+
:decoration none
|
88
|
+
|
89
|
+
span
|
90
|
+
:padding
|
91
|
+
:left 15px
|
92
|
+
:right 15px
|
93
|
+
|
94
|
+
.add_child
|
95
|
+
:background url(/images/admin/plus.png) no-repeat 0 50%
|
96
|
+
|
97
|
+
.remove
|
98
|
+
:background url(/images/admin/minus.png) no-repeat 0 50%
|
99
|
+
|
100
|
+
#actions
|
101
|
+
|
102
|
+
form
|
103
|
+
:display inline
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{radiant-images-extension}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["squaretalent"]
|
12
|
+
s.date = %q{2010-09-16}
|
13
|
+
s.description = %q{Image Radiant Extension management tool, meant only to be useful to pages and extensions that need to require images.}
|
14
|
+
s.email = %q{info@squaretalent.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"app/controllers/admin/images_controller.rb",
|
26
|
+
"app/models/image.rb",
|
27
|
+
"app/views/admin/images/_bottom.haml",
|
28
|
+
"app/views/admin/images/_fields.haml",
|
29
|
+
"app/views/admin/images/_fields_bottom.haml",
|
30
|
+
"app/views/admin/images/_fields_top.haml",
|
31
|
+
"app/views/admin/images/_image.haml",
|
32
|
+
"app/views/admin/images/edit.haml",
|
33
|
+
"app/views/admin/images/index.haml",
|
34
|
+
"app/views/admin/images/new.haml",
|
35
|
+
"app/views/admin/images/remove.haml",
|
36
|
+
"config/locales/en.yml",
|
37
|
+
"config/routes.rb",
|
38
|
+
"cucumber.yml",
|
39
|
+
"db/migrate/20100601042237_create_images.rb",
|
40
|
+
"db/migrate/20100602044124_add_position_to_images.rb",
|
41
|
+
"features/support/env.rb",
|
42
|
+
"features/support/paths.rb",
|
43
|
+
"images_extension.rb",
|
44
|
+
"lib/images/interface/admin/images.rb",
|
45
|
+
"lib/images/tags/image.rb",
|
46
|
+
"lib/tasks/images_extension_tasks.rake",
|
47
|
+
"public/images/extensions/images/missing_icon.png",
|
48
|
+
"public/images/extensions/images/missing_normal.png",
|
49
|
+
"public/images/extensions/images/missing_preview.png",
|
50
|
+
"public/javascripts/admin/extensions/images/edit.js",
|
51
|
+
"public/stylesheets/sass/admin/extensions/images/edit.sass",
|
52
|
+
"public/stylesheets/sass/admin/extensions/images/index.sass",
|
53
|
+
"radiant-images-extension.gemspec",
|
54
|
+
"spec/controllers/admin/images_controller_spec.rb",
|
55
|
+
"spec/datasets/images.rb",
|
56
|
+
"spec/lib/images/tags/image_spec.rb",
|
57
|
+
"spec/models/image_spec.rb",
|
58
|
+
"spec/spec.opts",
|
59
|
+
"spec/spec_helper.rb"
|
60
|
+
]
|
61
|
+
s.homepage = %q{http://github.com/squaretalent/radiant-images-extension}
|
62
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
63
|
+
s.require_paths = ["lib"]
|
64
|
+
s.rubygems_version = %q{1.3.7}
|
65
|
+
s.summary = %q{Images Extension for Radiant CMS}
|
66
|
+
s.test_files = [
|
67
|
+
"spec/controllers/admin/images_controller_spec.rb",
|
68
|
+
"spec/datasets/images.rb",
|
69
|
+
"spec/lib/images/tags/image_spec.rb",
|
70
|
+
"spec/models/image_spec.rb",
|
71
|
+
"spec/spec_helper.rb"
|
72
|
+
]
|
73
|
+
|
74
|
+
if s.respond_to? :specification_version then
|
75
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
76
|
+
s.specification_version = 3
|
77
|
+
|
78
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
79
|
+
s.add_runtime_dependency(%q<paperclip>, ["~> 2.3.1.1"])
|
80
|
+
s.add_runtime_dependency(%q<aws-s3>, [">= 0.6.2"])
|
81
|
+
s.add_runtime_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
82
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
83
|
+
s.add_development_dependency(%q<rr>, [">= 1.0.0"])
|
84
|
+
else
|
85
|
+
s.add_dependency(%q<paperclip>, ["~> 2.3.1.1"])
|
86
|
+
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
87
|
+
s.add_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
88
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
89
|
+
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
90
|
+
end
|
91
|
+
else
|
92
|
+
s.add_dependency(%q<paperclip>, ["~> 2.3.1.1"])
|
93
|
+
s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
|
94
|
+
s.add_dependency(%q<acts_as_list>, [">= 0.1.2"])
|
95
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
96
|
+
s.add_dependency(%q<rr>, [">= 1.0.0"])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Admin::ImagesController do
|
4
|
+
dataset :users
|
5
|
+
dataset :images
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@image = images(:first)
|
9
|
+
@images = Image.all
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
context 'user not logged in' do
|
14
|
+
|
15
|
+
it 'should redirect to login path' do
|
16
|
+
get :index
|
17
|
+
response.should redirect_to login_path
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'user logged in' do
|
23
|
+
|
24
|
+
before :each do
|
25
|
+
login_as :admin
|
26
|
+
stub(AWS::S3::Base).establish_connection!
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'index action' do
|
30
|
+
|
31
|
+
it 'should render the index template on index action' do
|
32
|
+
get :index
|
33
|
+
response.should render_template(:index)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have a list of images' do
|
37
|
+
get :index
|
38
|
+
assigns(:images).should == @images
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'show action' do
|
44
|
+
|
45
|
+
it 'should redirect to the edit action' do
|
46
|
+
get :show, :id => @image.id
|
47
|
+
response.should redirect_to edit_admin_image_url(@image)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context 'edit action' do
|
53
|
+
|
54
|
+
it 'should render the edit template' do
|
55
|
+
get :edit, :id => @image.id
|
56
|
+
response.should render_template(:edit)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should redirect to the index on invalid image id' do
|
60
|
+
get :edit, :id => 999999
|
61
|
+
response.should redirect_to admin_images_url
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'new action' do
|
67
|
+
|
68
|
+
it 'should render the new template' do
|
69
|
+
get :new
|
70
|
+
response.should render_template(:new)
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'update action' do
|
76
|
+
|
77
|
+
it 'should redirect to the index on valid image' do
|
78
|
+
put :update, :id => @image.id
|
79
|
+
response.should redirect_to admin_images_url
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should render the edit template on invalid model' do
|
83
|
+
any_instance_of(Image, :valid? => false)
|
84
|
+
put :update, :id => @image.id
|
85
|
+
response.should render_template(:edit)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'create action' do
|
91
|
+
|
92
|
+
it "create action should render new template when model is invalid" do
|
93
|
+
stub.instance_of(Image).valid? {false}
|
94
|
+
post :create
|
95
|
+
response.should render_template(:new)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "create action should redirect when model is valid" do
|
99
|
+
stub.instance_of(Image).valid? {true}
|
100
|
+
post :create
|
101
|
+
response.should redirect_to admin_images_url
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'remove action' do
|
108
|
+
|
109
|
+
it 'should render the remove template' do
|
110
|
+
get :remove, :id => @image.id
|
111
|
+
response.should render_template(:remove)
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'destroy action' do
|
118
|
+
|
119
|
+
it 'should redirect to the index' do
|
120
|
+
# we need to stop destroy_attached_files running (as it'll error with no S3 details)
|
121
|
+
mock(@images[1]).destroy_attached_files
|
122
|
+
|
123
|
+
@images[1].destroy
|
124
|
+
delete :destroy, :id => @images[1].id
|
125
|
+
response.should redirect_to admin_images_url
|
126
|
+
Image.exists?(@images[1].id).should be_false
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ImagesDataset < Dataset::Base
|
2
|
+
def load
|
3
|
+
images = [ :first, :second, :third, :fourth, :fifth ]
|
4
|
+
|
5
|
+
images.each_with_index do |image, i|
|
6
|
+
create_record :image, image.to_sym,
|
7
|
+
:title => image.to_s,
|
8
|
+
:caption => 'brief description',
|
9
|
+
:asset_file_name => "#{image.to_s}.png",
|
10
|
+
:asset_content_type => "image/png",
|
11
|
+
:asset_file_size => i+1*1000,
|
12
|
+
:position => i+1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,240 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe Images::Tags::Image do
|
4
|
+
dataset :pages
|
5
|
+
dataset :images
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@images = Image.all
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
stub(AWS::S3::Base).establish_connection!
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '<r:images>' do
|
16
|
+
|
17
|
+
it 'should render without errors' do
|
18
|
+
content = '<r:images></r:images>'
|
19
|
+
pages(:home).should render(content)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should allow tags in the images namespace to be used without defining their namespace' do
|
23
|
+
content = '<r:images><r:each></r:each></r:images>'
|
24
|
+
pages(:home).should render(content)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should reference an image given its title' do
|
28
|
+
image = @images[2]
|
29
|
+
content = '<r:images title="' + image.title + '"><r:images:url /></r:images>'
|
30
|
+
pages(:home).should render(content).as(image.asset.url)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise an exception if an image title is used that does not exist' do
|
34
|
+
content = '<r:images title="doesntreallyexist"><r:images:url /></r:images>'
|
35
|
+
lambda { pages(:home).render(content) }.should raise_error
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '<r:images:each>' do
|
41
|
+
|
42
|
+
it 'should run through all of our images' do
|
43
|
+
content = '<r:images:each>test!</r:images:each>'
|
44
|
+
expected = ''
|
45
|
+
@images.length.times { expected += 'test!' }
|
46
|
+
pages(:home).should render(content).as(expected)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should be running through the image objects' do
|
50
|
+
content = '<r:images:each><r:images:url/></r:images:each>'
|
51
|
+
expected = ''
|
52
|
+
@images.each { |image| expected += image.asset.url }
|
53
|
+
pages(:home).should render(content).as(expected)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should only run through however many images we specify with limit' do
|
57
|
+
content = '<r:images:each limit="2"><r:images:url/></r:images:each>'
|
58
|
+
expected = ''
|
59
|
+
@images[0..1].each { |image| expected += image.asset.url }
|
60
|
+
pages(:home).should render(content).as(expected)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should start at the image number we give it using offset' do
|
64
|
+
content = '<r:images:each limit="2" offset="1"><r:images:url/></r:images:each>'
|
65
|
+
expected = ''
|
66
|
+
@images[1..2].each { |image| expected += image.asset.url }
|
67
|
+
pages(:home).should render(content).as(expected)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should display images in the order we give' do
|
71
|
+
# asc
|
72
|
+
content = '<r:images:each order="asc" by="position"><r:images:url/></r:images:each>'
|
73
|
+
expected = ''
|
74
|
+
@images.each { |image| expected += image.asset.url }
|
75
|
+
pages(:home).should render(content).as(expected)
|
76
|
+
|
77
|
+
#desc
|
78
|
+
content = '<r:images:each order="desc" by="position"><r:images:url/></r:images:each>'
|
79
|
+
expected = ''
|
80
|
+
@images.reverse.each { |image| expected += image.asset.url }
|
81
|
+
pages(:home).should render(content).as(expected)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should allow us to order images by title' do
|
85
|
+
content = '<r:images:each order="asc" by="title"><r:images:url/></r:images:each>'
|
86
|
+
expected = ''
|
87
|
+
@images.sort! { |a,b| a.title <=> b.title }
|
88
|
+
@images.each { |image| expected += image.asset.url }
|
89
|
+
pages(:home).should render(content).as(expected)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '<r:images:first>' do
|
95
|
+
|
96
|
+
it 'should render the first image' do
|
97
|
+
content = '<r:images:first><r:images:url/></r:images:first>'
|
98
|
+
expected = @images.first.asset.url
|
99
|
+
pages(:home).should render(content).as(expected)
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe '<r:images:if_first>' do
|
105
|
+
|
106
|
+
it 'should expand the tag if the image is the first' do
|
107
|
+
content = '<r:images><r:each><r:if_first><r:url /></r:if_first></r:each></r:images>'
|
108
|
+
expected = @images.first.asset.url
|
109
|
+
pages(:home).should render(content).as(expected)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '<r:images:unless_first>' do
|
115
|
+
|
116
|
+
it 'should expand the tag if the image is not the first' do
|
117
|
+
content = '<r:images><r:each><r:unless_first><r:url /></r:unless_first></r:each></r:images>'
|
118
|
+
expected = ''
|
119
|
+
|
120
|
+
@images.each do |image|
|
121
|
+
expected += image.asset.url unless image == @images.first
|
122
|
+
end
|
123
|
+
|
124
|
+
pages(:home).should render(content).as(expected)
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '<r:if_images>' do
|
130
|
+
|
131
|
+
it 'should expand the contents if there are images' do
|
132
|
+
content = '<r:images:if_images>test text</r:images:if_images>'
|
133
|
+
expected = 'test text'
|
134
|
+
pages(:home).should render(content).as(expected)
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should not expand the contents if there are no images' do
|
138
|
+
Image.delete_all
|
139
|
+
content = '<r:images:if_images>test text</r:images:if_images>'
|
140
|
+
expected = ''
|
141
|
+
pages(:home).should render(content).as(expected)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should expand if the min count is equal to the image count' do
|
145
|
+
min_count = Image.count
|
146
|
+
content = '<r:images:if_images min_count="' + min_count.to_s + '">test text</r:images:if_images>'
|
147
|
+
expected = 'test text'
|
148
|
+
pages(:home).should render(content).as(expected)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should not expand if the min count is greater than the image count' do
|
152
|
+
min_count = Image.count + 1
|
153
|
+
content = '<r:images:if_images min_count="' + min_count.to_s + '">test text</r:images:if_images>'
|
154
|
+
expected = ''
|
155
|
+
pages(:home).should render(content).as(expected)
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
describe '<r:unless_images>' do
|
161
|
+
|
162
|
+
it 'should not the contents if there are images' do
|
163
|
+
content = '<r:images:unless_images>test text</r:images:unless_images>'
|
164
|
+
expected = ''
|
165
|
+
pages(:home).should render(content).as(expected)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should expand the contents if there are no images' do
|
169
|
+
Image.delete_all
|
170
|
+
content = '<r:images:unless_images>test text</r:images:unless_images>'
|
171
|
+
expected = 'test text'
|
172
|
+
pages(:home).should render(content).as(expected)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should not expand if the min count is equal to the image count' do
|
176
|
+
min_count = Image.count
|
177
|
+
content = '<r:images:unless_images min_count="' + min_count.to_s + '">test text</r:images:unless_images>'
|
178
|
+
expected = ''
|
179
|
+
pages(:home).should render(content).as(expected)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should expand if the min count is greater than the image count' do
|
183
|
+
min_count = Image.count + 1
|
184
|
+
content = '<r:images:unless_images min_count="' + min_count.to_s + '">test text</r:images:unless_images>'
|
185
|
+
expected = 'test text'
|
186
|
+
pages(:home).should render(content).as(expected)
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
|
191
|
+
describe '<r:images:url/>' do
|
192
|
+
|
193
|
+
it 'should output the url for a valid image' do
|
194
|
+
content = '<r:images title="' + @images.first.title + '"><r:images:url/></r:images>'
|
195
|
+
expected = @images.first.asset.url
|
196
|
+
pages(:home).should render(content).as(expected)
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
201
|
+
describe '<r:images:title/>' do
|
202
|
+
|
203
|
+
it 'should output the title for a valid image' do
|
204
|
+
content = '<r:images title="' + @images.first.title + '"><r:images:title/></r:images>'
|
205
|
+
expected = @images.first.title
|
206
|
+
pages(:home).should render(content).as(expected)
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '<r:images:tag/>' do
|
212
|
+
|
213
|
+
it 'should output a valid image tag when given a valid image' do
|
214
|
+
content = '<r:images title="' + @images.first.title + '"><r:images:tag /></r:images>'
|
215
|
+
expected = '<img src="' + @images.first.asset.url + '" alt="' + @images.first.title + '" />'
|
216
|
+
pages(:home).should render(content).as(expected)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'should output a valid image tag when specifying an image by title' do
|
220
|
+
content = '<r:images:tag title="' + @images.first.title + '" />'
|
221
|
+
expected = '<img src="' + @images.first.asset.url + '" alt="' + @images.first.title + '" />'
|
222
|
+
pages(:home).should render(content).as(expected)
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'should output an image tag with the specified size' do
|
226
|
+
content = '<r:images:tag title="' + @images.first.title + '" size="icon" />'
|
227
|
+
expected = '<img src="' + @images.first.asset.url(:icon) + '" alt="' + @images.first.title + '" />'
|
228
|
+
pages(:home).should render(content).as(expected)
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should use the given alt text specified' do
|
232
|
+
content = '<r:images:tag title="' + @images.first.title + '" alt="new alt text" />'
|
233
|
+
expected = '<img src="' + @images.first.asset.url + '" alt="new alt text" />'
|
234
|
+
pages(:home).should render(content).as(expected)
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
end
|