refinerycms-images 2.1.5 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/refinery/admin/images_controller.rb +62 -49
  3. data/app/helpers/refinery/admin/images_helper.rb +6 -6
  4. data/app/models/refinery/image.rb +16 -61
  5. data/app/models/refinery/thumbnail_dimensions.rb +97 -0
  6. data/app/views/refinery/admin/images/_actions.html.erb +6 -7
  7. data/app/views/refinery/admin/images/_form.html.erb +30 -12
  8. data/app/views/refinery/admin/images/_grid_view.html.erb +9 -16
  9. data/app/views/refinery/admin/images/_list_view.html.erb +4 -4
  10. data/app/views/refinery/admin/images/_list_view_image.html.erb +24 -15
  11. data/app/views/refinery/admin/images/index.html.erb +3 -3
  12. data/app/views/refinery/admin/images/insert.html.erb +1 -1
  13. data/config/locales/ca.yml +44 -0
  14. data/config/locales/cs.yml +5 -0
  15. data/config/locales/de.yml +5 -0
  16. data/config/locales/en.yml +4 -0
  17. data/config/locales/fr.yml +4 -0
  18. data/config/locales/it.yml +4 -14
  19. data/config/locales/nl.yml +1 -1
  20. data/config/routes.rb +1 -1
  21. data/db/migrate/20140814073957_add_title_and_alt_to_refinery_images.rb +8 -0
  22. data/db/migrate/20150430171341_translate_refinery_images.rb +22 -0
  23. data/lib/generators/refinery/images/templates/config/initializers/refinery/images.rb.erb +2 -5
  24. data/lib/refinery/images.rb +4 -1
  25. data/lib/refinery/images/configuration.rb +4 -6
  26. data/lib/refinery/images/dragonfly.rb +38 -27
  27. data/lib/refinery/images/engine.rb +2 -3
  28. data/license.md +1 -1
  29. data/refinerycms-images.gemspec +6 -3
  30. data/spec/factories/image.rb +6 -2
  31. data/spec/features/refinery/admin/images_spec.rb +49 -136
  32. data/spec/lib/generators/refinery/images/images_generator_spec.rb +1 -1
  33. data/spec/lib/refinery/images/dragonfly_spec.rb +34 -0
  34. data/spec/models/refinery/image_spec.rb +81 -43
  35. data/spec/models/refinery/thumbnail_dimensions_spec.rb +18 -0
  36. data/spec/support/shared contexts/admin_images_tab.rb +17 -0
  37. data/spec/support/shared contexts/many_images.rb +5 -0
  38. data/spec/support/shared contexts/no_images.rb +3 -0
  39. data/spec/support/shared contexts/one_image.rb +3 -0
  40. data/spec/support/shared contexts/visual_editor_add_image.rb +31 -0
  41. data/spec/support/shared examples/image_deleter.rb +31 -0
  42. data/spec/support/shared examples/image_editor.rb +3 -0
  43. data/spec/support/shared examples/image_indexer.rb +118 -0
  44. data/spec/support/shared examples/image_inserter.rb +53 -0
  45. data/spec/support/shared examples/image_previewer.rb +41 -0
  46. data/spec/support/shared examples/image_translator.rb +31 -0
  47. data/spec/support/shared examples/image_uploader.rb +37 -0
  48. data/spec/support/spec_helper.rb +19 -0
  49. data/test.html +126 -0
  50. metadata +64 -9
@@ -8,17 +8,16 @@ module Refinery
8
8
 
9
9
  config.autoload_paths += %W( #{config.root}/lib )
10
10
 
11
- initializer 'attach-refinery-images-with-dragonfly', :before => :build_middleware_stack do |app|
11
+ initializer 'attach-refinery-images-with-dragonfly', :before => :finisher_hook do |app|
12
12
  ::Refinery::Images::Dragonfly.configure!
13
13
  ::Refinery::Images::Dragonfly.attach!(app)
14
14
  end
15
15
 
16
- initializer "register refinery_images plugin" do
16
+ before_inclusion do
17
17
  Refinery::Plugin.register do |plugin|
18
18
  plugin.pathname = root
19
19
  plugin.name = 'refinery_images'
20
20
  plugin.menu_match = %r{refinery/image(_dialog)?s$}
21
- plugin.activity = { :class_name => :'refinery/image' }
22
21
  plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_images_path }
23
22
  end
24
23
  end
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2005-2013 [Resolve Digital](http://www.resolvedigital.com)
3
+ Copyright (c) 2005-2015 [Resolve Digital](http://resolve.digital)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.version = version
10
10
  s.summary = %q{Images extension for Refinery CMS}
11
11
  s.description = %q{Handles all image upload and processing functionality in Refinery CMS.}
12
- s.email = %q{info@refinerycms.com}
12
+ s.email = %q{refinerycms@p.arndt.io}
13
13
  s.homepage = %q{http://refinerycms.com}
14
14
  s.rubyforge_project = %q{refinerycms}
15
15
  s.authors = ['Philip Arndt', 'Uģis Ozols', 'Rob Yurkowski']
@@ -19,6 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- spec/*`.split("\n")
21
21
 
22
- s.add_dependency 'dragonfly', '~> 0.9.14'
23
- s.add_dependency 'refinerycms-core', version
22
+ s.add_dependency 'dragonfly', '~> 1.0.0'
23
+ s.add_dependency 'globalize', ['>= 4.0.0', '< 5.2']
24
+ s.add_dependency 'refinerycms-core', version
25
+
26
+ s.required_ruby_version = Refinery::Version.required_ruby_version
24
27
  end
@@ -1,9 +1,13 @@
1
1
  FactoryGirl.define do
2
2
  factory :image, :class => ::Refinery::Image do
3
- image Refinery.roots(:'refinery/images').join("spec/fixtures/beach.jpeg")
3
+ image Refinery.roots('refinery/images').join("spec/fixtures/beach.jpeg")
4
4
  end
5
5
 
6
6
  factory :alternate_image, :class => ::Refinery::Image do
7
- image Refinery.roots(:'refinery/images').join("spec/fixtures/beach-alternate.jpeg")
7
+ image Refinery.roots('refinery/images').join("spec/fixtures/beach-alternate.jpeg")
8
+ end
9
+
10
+ factory :another_image, :class => ::Refinery::Image do
11
+ image Refinery.roots('refinery/images').join("spec/fixtures/fathead.png")
8
12
  end
9
13
  end
@@ -1,161 +1,74 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe "AdminImages" do
5
- refinery_login_with :refinery_user
4
+ describe "the Admin Images Tab", type: :feature do
5
+ refinery_login
6
+ include_context 'admin images tab'
6
7
 
7
- context "when no images" do
8
- it "invites to add one" do
9
- visit refinery.admin_images_path
10
- page.should have_content(::I18n.t('no_images_yet', :scope => 'refinery.admin.images.records'))
11
- end
12
- end
8
+ context 'When there are no images' do
9
+ include_context 'no existing images'
13
10
 
14
- it "shows add new image link" do
15
- visit refinery.admin_images_path
16
- page.should have_content(::I18n.t('create_new_image', :scope => 'refinery.admin.images.actions'))
17
- page.should have_selector("a[href*='#{refinery.new_admin_image_path}']")
18
- end
19
-
20
- context "new/create" do
21
- it "uploads image", :js => true do
11
+ it 'says there are no images' do
22
12
  visit refinery.admin_images_path
23
-
24
- click_link ::I18n.t('create_new_image', :scope => 'refinery.admin.images.actions')
25
-
26
- page.should have_selector 'iframe#dialog_iframe'
27
-
28
- page.within_frame('dialog_iframe') do
29
- attach_file "image_image", Refinery.roots(:'refinery/images').
30
- join("spec/fixtures/image-with-dashes.jpg")
31
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
32
- end
33
-
34
- page.should have_content(::I18n.t('created', :scope => 'refinery.crudify', :what => "'Image With Dashes'"))
35
- Refinery::Image.count.should == 1
13
+ expect(page).to have_content(::I18n.t('no_images_yet', scope: 'refinery.admin.images.records'))
36
14
  end
37
15
 
38
- it "cannot upload a pdf", :js => true do
39
- visit refinery.admin_images_path
40
-
41
- click_link ::I18n.t('create_new_image', :scope => 'refinery.admin.images.actions')
42
-
43
- page.should have_selector 'iframe#dialog_iframe'
44
-
45
- page.within_frame('dialog_iframe') do
46
- attach_file "image_image", Refinery.roots(:'refinery/images').
47
- join("spec/fixtures/cape-town-tide-table.pdf")
48
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
49
- end
50
-
51
- page.within_frame('dialog_iframe') do
52
- page.should have_content(::I18n.t('incorrect_format', :scope => 'activerecord.errors.models.refinery/image'))
53
- end
54
- Refinery::Image.count.should == 0
55
- end
16
+ it_has_behaviour 'uploads images'
56
17
  end
57
18
 
58
- context "new/create - insert mode" do
59
- it "uploads image", :js => true do
60
- visit refinery.insert_admin_images_path(:modal => true, :wymedtior => true)
61
-
62
- attach_file "image_image", Refinery.roots(:'refinery/images').join("spec/fixtures/image-with-dashes.jpg")
63
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
64
-
65
- page.should have_selector('#existing_image_area', :visible => true)
66
- Refinery::Image.count.should == 1
67
- end
68
-
69
- it "gets error message when uploading non-image", :js => true do
70
- visit refinery.insert_admin_images_path(:modal => true, :wymedtior => true)
71
-
72
- attach_file "image_image", Refinery.roots(:'refinery/images').join("spec/fixtures/cape-town-tide-table.pdf")
73
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
74
-
75
- page.should have_selector('#upload_image_area', :visible => true)
76
- page.should have_content(::I18n.t('incorrect_format', :scope => 'activerecord.errors.models.refinery/image'))
77
- Refinery::Image.count.should == 0
78
- end
79
-
80
- it "gets error message when uploading non-image (when an image already exists)", :js => true do
81
- FactoryGirl.create(:image)
82
- visit refinery.insert_admin_images_path(:modal => true, :wymedtior => true)
83
-
84
- choose 'Upload'
85
- attach_file "image_image", Refinery.roots(:'refinery/images').join("spec/fixtures/cape-town-tide-table.pdf")
86
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
19
+ context 'When there is one image' do
20
+ include_context 'one image'
87
21
 
88
- page.should have_selector('#upload_image_area', :visible => true)
89
- page.should have_content(::I18n.t('incorrect_format', :scope => 'activerecord.errors.models.refinery/image'))
90
- Refinery::Image.count.should == 1
91
- end
22
+ it_has_behaviour 'indexes images'
23
+ it_has_behaviour 'shows list and grid views'
24
+ it_has_behaviour 'shows an image preview'
25
+ it_has_behaviour 'deletes an image'
26
+ it_has_behaviour 'edits an image'
27
+ it_has_behaviour 'uploads images'
28
+ it_has_behaviour 'translates an image'
92
29
  end
93
30
 
94
- context "when an image exists" do
95
- let!(:image) { FactoryGirl.create(:image) }
96
-
97
- context "edit/update" do
98
- it "updates image" do
99
- visit refinery.admin_images_path
100
- page.should have_selector("a[href='#{refinery.edit_admin_image_path(image)}']")
101
-
102
- click_link ::I18n.t('edit', :scope => 'refinery.admin.images')
103
-
104
- page.should have_content("Use current image or replace it with this one...")
105
- page.should have_selector("a[href*='#{refinery.admin_images_path}']")
106
-
107
- attach_file "image_image", Refinery.roots(:'refinery/images').join("spec/fixtures/beach.jpeg")
108
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
109
-
110
- page.should have_content(::I18n.t('updated', :scope => 'refinery.crudify', :what => "'Beach'"))
111
- Refinery::Image.count.should == 1
112
-
113
- lambda { click_link "View this image" }.should_not raise_error
114
- end
115
-
116
- it "doesn't allow updating if image has different file name" do
117
- visit refinery.edit_admin_image_path(image)
31
+ context 'When there are many images' do
32
+ include_context 'many images'
118
33
 
119
- attach_file "image_image", Refinery.roots(:'refinery/images').join("spec/fixtures/fathead.png")
120
- click_button ::I18n.t('save', :scope => 'refinery.admin.form_actions')
121
-
122
- page.should have_content(::I18n.t("different_file_name",
123
- :scope => "activerecord.errors.models.refinery/image"))
124
- end
125
- end
34
+ it_has_behaviour 'indexes images'
35
+ it_has_behaviour 'shows list and grid views'
36
+ it_has_behaviour 'paginates the list of images'
37
+ it_has_behaviour 'shows an image preview'
38
+ it_has_behaviour 'deletes an image'
39
+ it_has_behaviour 'uploads images'
40
+ it_has_behaviour 'edits an image'
41
+ end
42
+ end
126
43
 
127
- context "destroy" do
128
- it "removes image" do
129
- visit refinery.admin_images_path
130
- page.should have_selector("a[href='#{refinery.admin_image_path(image)}']")
44
+ describe 'Page Visual Editor - Add Image' do
131
45
 
132
- click_link ::I18n.t('delete', :scope => 'refinery.admin.images')
46
+ refinery_login
133
47
 
134
- page.should have_content(::I18n.t('destroyed', :scope => 'refinery.crudify', :what => "'Beach'"))
135
- Refinery::Image.count.should == 0
136
- end
137
- end
48
+ include_context 'Visual Editor - add image'
138
49
 
139
- context "download" do
140
- it "succeeds" do
141
- visit refinery.admin_images_path
50
+ context 'When there are no images' do
51
+ include_context 'no existing images'
52
+ it_has_behaviour 'uploads images'
53
+ end
142
54
 
143
- lambda { click_link "View this image" }.should_not raise_error
144
- end
145
- end
55
+ context 'When there is one image' do
56
+ include_context 'one image'
146
57
 
147
- describe "switch view" do
148
- it "shows images in grid" do
149
- visit refinery.admin_images_path
150
- page.should have_content(::I18n.t('switch_to', :view_name => 'list', :scope => 'refinery.admin.images.index.view'))
151
- page.should have_selector("a[href='#{refinery.admin_images_path(:view => 'list')}']")
58
+ it_has_behaviour 'indexes images'
59
+ it_has_behaviour 'paginates the list of images'
60
+ it_has_behaviour 'uploads images'
61
+ it_has_behaviour 'inserts images'
62
+ end
152
63
 
153
- click_link "Switch to list view"
64
+ context 'When there are many images' do
65
+ include_context 'many images'
154
66
 
155
- page.should have_content(::I18n.t('switch_to', :view_name => 'grid', :scope => 'refinery.admin.images.index.view'))
156
- page.should have_selector("a[href='#{refinery.admin_images_path(:view => 'grid')}']")
157
- end
158
- end
67
+ it_has_behaviour 'indexes images'
68
+ it_has_behaviour 'paginates the list of images'
69
+ it_has_behaviour 'uploads images'
70
+ it_has_behaviour 'inserts images'
159
71
  end
72
+
160
73
  end
161
74
  end
@@ -13,7 +13,7 @@ module Refinery
13
13
  end
14
14
 
15
15
  specify do
16
- destination_root.should have_structure {
16
+ expect(destination_root).to have_structure {
17
17
  directory "config" do
18
18
  directory "initializers" do
19
19
  directory "refinery" do
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Refinery
4
+
5
+ describe Dragonfly do
6
+ def configure_dragonfly(name, verify)
7
+ app = ::Dragonfly.app(name)
8
+
9
+ app.configure do
10
+ verify_urls verify
11
+ end
12
+ end
13
+
14
+ context 'when verify_urls is true' do
15
+ before do
16
+ configure_dragonfly(:app1, true)
17
+ end
18
+ it 'it is reflected in the dragonfly configuration' do
19
+ expect(Dragonfly.app(:app1).server.verify_urls).to be(true)
20
+ end
21
+ end
22
+
23
+ context 'when verify_urls is false' do
24
+ before do
25
+ configure_dragonfly(:app2, false)
26
+ end
27
+ it 'it is reflected in the dragonfly configuration' do
28
+ expect(Dragonfly.app(:app2).server.verify_urls).to be(false)
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+
@@ -1,38 +1,42 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe Image do
4
+ describe Image, :type => :model do
5
5
 
6
- let(:image) { FactoryGirl.build(:image) }
6
+ let(:image) { FactoryGirl.build(:image) }
7
7
  let(:created_image) { FactoryGirl.create(:image) }
8
+ let(:titled_image) { FactoryGirl.create(:image, image_title: 'Image Title')}
9
+ let(:image_with_alt_text) { FactoryGirl.create(:image, image_alt: 'Alt Text')}
10
+ let(:image_with_sha) {FactoryGirl.create(:image)}
11
+ let(:image_without_sha) {FactoryGirl.create(:image)}
8
12
 
9
13
  describe "validations" do
10
14
  describe "valid #image" do
11
15
  before do
12
- @file = Refinery.roots(:'refinery/images').join("spec/fixtures/beach.jpeg")
13
- Images.stub(:max_image_size).and_return(File.read(@file).size + 10.megabytes)
16
+ @file = Refinery.roots('refinery/images').join("spec/fixtures/beach.jpeg")
17
+ allow(Images).to receive(:max_image_size).and_return(File.read(@file).size + 10.megabytes)
14
18
  end
15
19
 
16
20
  it "should be valid when size does not exceed .max_image_size" do
17
- Image.new(:image => @file).should be_valid
21
+ expect(Image.new(:image => @file)).to be_valid
18
22
  end
19
23
  end
20
24
 
21
25
  describe "too large #image" do
22
26
  before do
23
- @file = Refinery.roots(:'refinery/images').join("spec/fixtures/beach.jpeg")
24
- Images.stub(:max_image_size).and_return(0)
27
+ @file = Refinery.roots('refinery/images').join("spec/fixtures/beach.jpeg")
28
+ allow(Images).to receive(:max_image_size).and_return(0)
25
29
  @image = Image.new(:image => @file)
26
30
  end
27
31
 
28
32
  it "should not be valid when size exceeds .max_image_size" do
29
- @image.should_not be_valid
33
+ expect(@image).not_to be_valid
30
34
  end
31
35
 
32
36
  it "should contain an error message" do
33
37
  @image.valid?
34
- @image.errors.should_not be_empty
35
- @image.errors[:image].should == ["Image should be smaller than #{Images.max_image_size} bytes in size"]
38
+ expect(@image.errors).not_to be_empty
39
+ expect(@image.errors[:image]).to eq(["Image should be smaller than #{Images.max_image_size} bytes in size"])
36
40
  end
37
41
  end
38
42
 
@@ -43,51 +47,85 @@ module Refinery
43
47
 
44
48
  it "has an error message" do
45
49
  @image.valid?
46
- @image.errors.should_not be_empty
47
- @image.errors[:image].should == ["You must specify an image for upload"]
50
+ expect(@image.errors).not_to be_empty
51
+ expect(@image.errors[:image]).to eq(["You must specify an image for upload"])
48
52
  end
49
53
  end
50
54
 
51
55
  context "when image exists" do
52
56
  it "doesn't allow to replace it with image which has different file name" do
53
- created_image.image = Refinery.roots(:'refinery/images').join("spec/fixtures/beach-alternate.jpeg")
54
- created_image.should_not be_valid
55
- created_image.should have_at_least(1).error_on(:image_name)
57
+ created_image.image = Refinery.roots('refinery/images').join("spec/fixtures/beach-alternate.jpeg")
58
+ expect(created_image).not_to be_valid
59
+ expect(created_image.errors.messages[:image_name].size).to be >= 1
56
60
  end
57
61
 
58
62
  it "allows to replace it with image which has the same file name" do
59
- created_image.image = Refinery.roots(:'refinery/images').join("spec/fixtures/beach.jpeg")
60
- created_image.should be_valid
63
+ created_image.image = Refinery.roots('refinery/images').join("spec/fixtures/beach.jpeg")
64
+ expect(created_image).to be_valid
61
65
  end
62
66
  end
63
67
  end
64
68
 
65
- context "image url" do
69
+ describe "image url" do
66
70
  it "responds to .thumbnail" do
67
- image.should respond_to(:thumbnail)
71
+ expect(image).to respond_to(:thumbnail)
68
72
  end
69
73
 
70
74
  it "contains its filename at the end" do
71
- created_image.url.split('/').last.should == created_image.image_name
75
+ expect(created_image.url.split('/').last).to match(/\A#{created_image.image_name}/)
72
76
  end
73
77
 
74
78
  it "becomes different when supplying geometry" do
75
- created_image.url.should_not == created_image.thumbnail(:geometry => '200x200').url
79
+ expect(created_image.url).not_to eq(created_image.thumbnail(:geometry => '200x200').url)
76
80
  end
77
81
 
78
82
  it "has different urls for each geometry string" do
79
- created_image.thumbnail(:geometry => '200x200').url.should_not == created_image.thumbnail(:geometry => '200x201').url
83
+ expect(created_image.thumbnail(:geometry => '200x200').url).not_to eq(created_image.thumbnail(:geometry => '200x201').url)
84
+ end
85
+
86
+ it "doesn't call thumb when geometry is nil" do
87
+ expect(created_image.image).not_to receive(:thumb)
88
+ created_image.thumbnail(geometry: nil)
80
89
  end
81
90
 
82
91
  it "uses right geometry when given a thumbnail name" do
83
92
  name, geometry = Refinery::Images.user_image_sizes.first
84
- created_image.thumbnail(:geometry => name).url.should == created_image.thumbnail(:geometry => geometry).url
93
+ expect(created_image.thumbnail(:geometry => name).url).to eq(created_image.thumbnail(:geometry => geometry).url)
94
+ end
95
+
96
+ it "can strip a thumbnail" do
97
+ expect(created_image.thumbnail(:strip => true).url.blank?).to eq(false)
85
98
  end
99
+
100
+ it "can resize and strip a thumbnail" do
101
+ expect(created_image.thumbnail(:geometry => '200x200', :strip => true).url.blank?).to eq(false)
102
+ end
103
+
86
104
  end
87
105
 
88
106
  describe "#title" do
89
- it "returns a titleized version of the filename" do
90
- image.title.should == "Beach"
107
+ context 'when a specific title has not been given' do
108
+ it "returns a titleized version of the filename" do
109
+ expect(image.title).to eq("Beach")
110
+ end
111
+ end
112
+ context 'when a specific title has been given' do
113
+ it 'returns that title' do
114
+ expect(titled_image.title).to eq('Image Title')
115
+ end
116
+ end
117
+ end
118
+
119
+ describe "#alt" do
120
+ context 'when no alt attribute is given' do
121
+ it "returns the title" do
122
+ expect(image.alt).to eq(image.title)
123
+ end
124
+ end
125
+ context 'when an alt attribute is given' do
126
+ it 'returns that alt attribute' do
127
+ expect(image_with_alt_text.alt).to eq('Alt Text')
128
+ end
91
129
  end
92
130
  end
93
131
 
@@ -95,70 +133,70 @@ module Refinery
95
133
  context "dialog is true" do
96
134
  context "has_size_options is true" do
97
135
  it "returns image count specified by Images.pages_per_dialog_that_have_size_options option" do
98
- ::Refinery::Image.per_page(true, true).should == Images.pages_per_dialog_that_have_size_options
136
+ expect(::Refinery::Image.per_page(true, true)).to eq(Images.pages_per_dialog_that_have_size_options)
99
137
  end
100
138
  end
101
139
 
102
140
  context "has_size_options is false" do
103
141
  it "returns image count specified by Images.pages_per_dialog option" do
104
- ::Refinery::Image.per_page(true).should == Images.pages_per_dialog
142
+ expect(::Refinery::Image.per_page(true)).to eq(Images.pages_per_dialog)
105
143
  end
106
144
  end
107
145
  end
108
146
 
109
147
  context "dialog is false" do
110
148
  it "returns image count specified by Images.pages_per_admin_index option" do
111
- ::Refinery::Image.per_page.should == Images.pages_per_admin_index
149
+ expect(::Refinery::Image.per_page).to eq(Images.pages_per_admin_index)
112
150
  end
113
151
  end
114
152
  end
115
153
 
116
154
  describe ".user_image_sizes" do
117
155
  it "returns a hash" do
118
- Refinery::Images.user_image_sizes.should be_a_kind_of(Hash)
156
+ expect(Refinery::Images.user_image_sizes).to be_a_kind_of(Hash)
119
157
  end
120
158
  end
121
159
 
122
160
  # The sample image has dimensions 500x375
123
161
  describe '#thumbnail_dimensions returns correctly with' do
124
162
  it 'nil' do
125
- created_image.thumbnail_dimensions(nil).should == { :width => 500, :height => 375 }
163
+ expect(created_image.thumbnail_dimensions(nil)).to eq({ :width => 500, :height => 375 })
126
164
  end
127
165
 
128
166
  it '200x200#ne' do
129
- created_image.thumbnail_dimensions('200x200#ne').should == { :width => 200, :height => 200 }
167
+ expect(created_image.thumbnail_dimensions('200x200#ne')).to eq({ :width => 200, :height => 200 })
130
168
  end
131
169
 
132
170
  it '100x150#c' do
133
- created_image.thumbnail_dimensions('100x150#c').should == { :width => 100, :height => 150 }
171
+ expect(created_image.thumbnail_dimensions('100x150#c')).to eq({ :width => 100, :height => 150 })
134
172
  end
135
173
 
136
174
  it '250x250>' do
137
- created_image.thumbnail_dimensions('250x250>').should == { :width => 250, :height => 188 }
175
+ expect(created_image.thumbnail_dimensions('250x250>')).to eq({ :width => 250, :height => 188 })
138
176
  end
139
177
 
140
178
  it '600x375>' do
141
- created_image.thumbnail_dimensions('600x375>').should == { :width => 500, :height => 375 }
179
+ expect(created_image.thumbnail_dimensions('600x375>')).to eq({ :width => 500, :height => 375 })
142
180
  end
143
181
 
144
182
  it '100x475>' do
145
- created_image.thumbnail_dimensions('100x475>').should == { :width => 100, :height => 75 }
183
+ expect(created_image.thumbnail_dimensions('100x475>')).to eq({ :width => 100, :height => 75 })
146
184
  end
147
185
 
148
186
  it '100x150' do
149
- created_image.thumbnail_dimensions('100x150').should == { :width => 100, :height => 75 }
187
+ expect(created_image.thumbnail_dimensions('100x150')).to eq({ :width => 100, :height => 75 })
150
188
  end
151
189
 
152
190
  it '200x150' do
153
- created_image.thumbnail_dimensions('200x150').should == { :width => 200, :height => 150 }
191
+ expect(created_image.thumbnail_dimensions('200x150')).to eq({ :width => 200, :height => 150 })
154
192
  end
155
193
 
156
194
  it '300x150' do
157
- created_image.thumbnail_dimensions('300x150').should == { :width => 200, :height => 150 }
195
+ expect(created_image.thumbnail_dimensions('300x150')).to eq({ :width => 200, :height => 150 })
158
196
  end
159
197
 
160
198
  it '5x5' do
161
- created_image.thumbnail_dimensions('5x5').should == { :width => 5, :height => 4 }
199
+ expect(created_image.thumbnail_dimensions('5x5')).to eq({ :width => 5, :height => 4 })
162
200
  end
163
201
  end
164
202
 
@@ -166,21 +204,21 @@ module Refinery
166
204
  let(:created_alternate_image) { FactoryGirl.create(:alternate_image) }
167
205
 
168
206
  it 'nil' do
169
- created_alternate_image.thumbnail_dimensions(nil).should == { :width => 376, :height => 184 }
207
+ expect(created_alternate_image.thumbnail_dimensions(nil)).to eq({ :width => 376, :height => 184 })
170
208
  end
171
209
 
172
210
  it '225x255>' do
173
- created_alternate_image.thumbnail_dimensions('225x255>').should == { :width => 225, :height => 110 }
211
+ expect(created_alternate_image.thumbnail_dimensions('225x255>')).to eq({ :width => 225, :height => 110 })
174
212
  end
175
213
  end
176
214
 
177
215
  describe '#thumbnail_dimensions returns correctly with user-defined geometries' do
178
216
  it ':medium' do
179
- created_image.thumbnail_dimensions(:medium).should == { :width => 225, :height => 169 }
217
+ expect(created_image.thumbnail_dimensions(:medium)).to eq({ :width => 225, :height => 169 })
180
218
  end
181
219
 
182
220
  it ':large' do
183
- created_image.thumbnail_dimensions(:large).should == { :width => 450, :height => 338 }
221
+ expect(created_image.thumbnail_dimensions(:large)).to eq({ :width => 450, :height => 338 })
184
222
  end
185
223
  end
186
224