artwork 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e56305fe5bd63752f1cf13ba018c3354b688b93
4
- data.tar.gz: 3c11975ed676de962d5ad35056957de662dc6582
3
+ metadata.gz: 573aa33bc1c5aefabf51ff8509dc7bd55fa6a09e
4
+ data.tar.gz: f8c0aefbcb4d513b3b52b41aa08efa4cc4a59ddf
5
5
  SHA512:
6
- metadata.gz: 161644ee8eb7fd885e020b8164cafdb0ad1fb9cc69a885c09af9668cef01fdb9c5ea509bc2f5871ab005a6afffe5fba533f748aeab405c793ebad9c9bbd7689c
7
- data.tar.gz: 3e92cee31bbfac880b0fb56de9f12a24ceb989f9ee826f1e486845cb2ef9a6cf2d098b75f68717bb8b0e34f95532b62121b230967d722271cbc66db89933ef0e
6
+ metadata.gz: 3362f10528462b3405e0a1959c48d935c1ae220e09564dfef9326f112bcb523444dca904e4f80848c7e4626c9077c14710c19d0cf0eec6da0433c82988f7ecba
7
+ data.tar.gz: aa4077dfae88ef932c291891f53553dc1f5382b95cca2b831abbd47db5302a1c219b0e0ee4bc5a39747d418fec51d8e9a86b636e70811a64ff4944e74d0c2c34
@@ -0,0 +1,44 @@
1
+ ## v0.7.0
2
+
3
+ **Backwards-incompatible changes**
4
+
5
+ - Renamed `Artwork.default_resolution` to `Artwork.base_resolution`
6
+ - Renamed `Artwork.actual_resolution_for` to `Artwork.actual_resolution_from`
7
+ and is now private
8
+
9
+ **Other changes**
10
+
11
+ - Added support for custom base resolutions via the following syntax:
12
+ `<%= artwork_tag @record, :cover, '800x@1200' %>`
13
+ - Added `Artwork.actual_resolution` (set via `Artwork.configure_for(request)`)
14
+ - Added support for responsive image sizes via the alternative sizes parameter
15
+ of `Artwork::Model.artwork_thumb_for(name, size, alternative_sizes = nil)`
16
+ Example usage:
17
+
18
+ Request full-width images if the current browser's viewport is 480 px or
19
+ less wide:
20
+
21
+ ```ruby
22
+ <%= artwork_tag @recrod, :cover, '800x', {480 => '320x@320'} %>
23
+ ```
24
+
25
+ ## v0.6.1
26
+
27
+ - Added `Artwork.actual_resolution_for(request)` which returns the current
28
+ client's browser width, in pixels.
29
+
30
+ ## v0.6.0
31
+
32
+ - Don't change viewport width & retina cookies when loaded in an iframe.
33
+
34
+ ## v0.5.0
35
+
36
+ No changes.
37
+
38
+ ## v0.4.2
39
+
40
+ - Set the cookies with `path=/`.
41
+
42
+ ## v0.4.1
43
+
44
+ - Compatibility with newer versions of the Paperclip gem.
data/README.md CHANGED
@@ -1,12 +1,27 @@
1
1
  # Artwork
2
2
 
3
- Automated user-resolution-based image size choosing for your Rails views, but
4
- done at the backend. Works for any browser. Delivers the information needed for
5
- the calculations (browser window's dimentions and device's pixel ratio) via a
6
- cookie. Supports only Paperclip attachments.
3
+ The Artwork gem provides simple server-side responsive images support for Rails
4
+ which is similar in concept to the `<picture>` tag spec but requires no
5
+ JavaScript, doesn't make extra requests and works in all browsers.
6
+
7
+ Currently it supports only Paperclip attachments, but that can be changed
8
+ failry easily.
7
9
 
8
10
  The gem should be thread-safe and should work with Rails 2.3 or newer.
9
11
 
12
+ ## How it works
13
+
14
+ To do this "magic", the gem needs some information from the browser. Two pieces
15
+ of knowledge travel from the browser to the server via a cookie:
16
+
17
+ - the browser window's dimentions (width in pixels)
18
+ - the device's pixel ratio
19
+
20
+ These values are set in a cookie as early as possible during the first page
21
+ load and then the page is reloaded with JavaScript. If these values change
22
+ later on, for example if the user resizes their browser, no automatic reloading
23
+ is performed.
24
+
10
25
  ## An example
11
26
 
12
27
  Say you've declared a default (base) resolution of 1440px. You design based on
@@ -56,7 +71,8 @@ Or install it yourself as:
56
71
 
57
72
  $ gem install artwork
58
73
 
59
- Add the following line at the top of your `<head>` section:
74
+ Add the following line at the top of your `<head>` section, as early as
75
+ possible, but **after** any `<meta viewport>` tags:
60
76
 
61
77
  <%= activate_resolution_independence %>
62
78
 
@@ -69,6 +85,11 @@ so you could prevent this if you add (*ABOVE* the top script):
69
85
  <style> .artwork-reload-splash body { display: none; } </style>
70
86
  <%= activate_resolution_independence %>
71
87
 
88
+ ### When you have a viewport meta tag
89
+
90
+ If you have `<meta viewport>` tags, place them **before** the
91
+ `activate_resolution_independence` call.
92
+
72
93
  ### Usage in frames
73
94
 
74
95
  The client-side code which checks for the current browser's resolutions will be
@@ -86,7 +107,7 @@ This has to happen before the `<%= activate_resolution_independence %>` call.
86
107
  Set the following variables in an app initializer:
87
108
 
88
109
  - `Artwork.supported_resolutions_list`
89
- - `Artwork.default_resolution`
110
+ - `Artwork.base_resolution`
90
111
 
91
112
  Name your Paperclip attachment styles using the following convention:
92
113
 
@@ -108,7 +129,7 @@ conventions will be ignored and will bypass the artwork auto-sizing logic.
108
129
 
109
130
  Configure the gem by putting the following code in `config/initializers/artwork.rb`:
110
131
 
111
- Artwork.default_resolution = 1440
132
+ Artwork.base_resolution = 1440
112
133
  Artwork.supported_resolutions_list = [1024, 1280, 1440, 1600, 1920, 2048, 3200, 3840]
113
134
 
114
135
  Include `Artwork::Model` in your models which have artworks.
@@ -122,12 +143,46 @@ the `artwork_tag` view helper. Example:
122
143
  <%= artwork_tag @film, :board, :'1440x', :image => {:class => 'poster'} %>
123
144
  <%= artwork_tag @gallery, :cover, :'900x' %>
124
145
 
146
+ ### Base (default) resolution
147
+
148
+ The base resolution defeined by `Artwork.base_resolution` is there to assist
149
+ in development and to make calculating the image width percentage in relation
150
+ to the viewport width easier.
151
+
152
+ For example, to define a half-width image in a setting where your base
153
+ resolution is 1600 px, you can use:
154
+
155
+ <%= artwork_tag @record, :cover, :'800x' %>
156
+
157
+ In general, it's convenient to set the base resolution to what your dev team's
158
+ screen width is.
159
+
160
+ ### Custom base resolutions
161
+
162
+ The gem supports per-tag base resolutions via the following syntax:
163
+
164
+ <%= artwork_tag @record, :cover, :'800x@1200' %>
165
+
166
+ This effectively means "size the image as 2/3 of the viewport width".
167
+
168
+ ### Different image sizes based on different browser widths
169
+
170
+ There is basic media query-like support built into
171
+ `Artwork::Model.artwork_thumb_for(name, size, alternative_sizes = nil)`.
172
+
173
+ For example, to request a full width image if the current browser's viewport
174
+ is 480px or less wide, you can use the following code:
175
+
176
+ ```ruby
177
+ <%= artwork_tag @recrod, :cover, '800x', {480 => '320x@320'} %>
178
+ ```
179
+
125
180
  ## Thumb Selection Algorithm
126
181
 
127
182
  The following criteria are taken into account for picking up the appropriate
128
183
  thumb name:
129
184
 
130
- - The `default_resolution` specified in the Artwork configuration file.
185
+ - The `base_resolution` specified in the Artwork configuration file.
131
186
  - The current resolition, approximated to the nearest supported resolution
132
187
  which is larger than the current user's one.
133
188
  - Whether or not the screen is retina.
@@ -154,7 +209,6 @@ For a thumb to be returned as matching, all of the following must be true:
154
209
 
155
210
  If no such thumb exist, the largest one will match.
156
211
 
157
-
158
212
  ## Contributing
159
213
 
160
214
  1. [Fork it](https://github.com/mitio/artwork/fork)
@@ -11,13 +11,13 @@ module Artwork
11
11
  set :supported_resolutions_list, list
12
12
  end
13
13
 
14
- def default_resolution
15
- get(:default_resolution) or @@default_resolution or raise "Please set #{__method__}"
14
+ def base_resolution
15
+ get(:base_resolution) or @@base_resolution or raise "Please set #{__method__}"
16
16
  end
17
17
 
18
- def default_resolution=(resolution)
19
- @@default_resolution ||= resolution
20
- set :default_resolution, resolution
18
+ def base_resolution=(resolution)
19
+ @@base_resolution ||= resolution
20
+ set :base_resolution, resolution
21
21
  end
22
22
 
23
23
  def load_2x_images?
@@ -29,26 +29,25 @@ module Artwork
29
29
  end
30
30
 
31
31
  def current_resolution
32
- get(:current_resolution) || default_resolution
32
+ get(:current_resolution) || base_resolution
33
33
  end
34
34
 
35
- def actual_resolution_for(request)
36
- browser_width = request.cookies['_width'].to_i
35
+ def current_resolution=(resolution)
36
+ set :current_resolution, resolution
37
+ end
37
38
 
38
- if browser_width > 0
39
- browser_width
40
- else
41
- default_resolution
42
- end
39
+ def actual_resolution
40
+ get(:actual_resolution) || base_resolution
43
41
  end
44
42
 
45
- def current_resolution=(resolution)
46
- set :current_resolution, resolution
43
+ def actual_resolution=(resolution)
44
+ set :actual_resolution, resolution
47
45
  end
48
46
 
49
47
  def configure_for(request)
50
48
  Artwork.load_2x_images = fetch_2x_images_flag_from(request)
51
49
  Artwork.current_resolution = current_resolution_from(request)
50
+ Artwork.actual_resolution = actual_resolution_from(request)
52
51
  end
53
52
 
54
53
  def reset_configuration
@@ -73,7 +72,7 @@ module Artwork
73
72
  def current_resolution_from(request)
74
73
  browser_width = request.cookies['_width'].to_i
75
74
 
76
- return default_resolution if browser_width.zero?
75
+ return base_resolution if browser_width.zero?
77
76
 
78
77
  supported_resolutions_list.each do |resolution|
79
78
  return resolution if browser_width <= resolution
@@ -81,5 +80,15 @@ module Artwork
81
80
 
82
81
  supported_resolutions_list.last
83
82
  end
83
+
84
+ def actual_resolution_from(request)
85
+ browser_width = request.cookies['_width'].to_i
86
+
87
+ if browser_width > 0
88
+ browser_width
89
+ else
90
+ base_resolution
91
+ end
92
+ end
84
93
  end
85
94
  end
@@ -2,10 +2,17 @@ require 'artwork/thumbnail'
2
2
 
3
3
  module Artwork
4
4
  module Model
5
- def artwork_thumb_for(attachment_name, size)
5
+ def artwork_thumb_for(attachment_name, size, alternative_sizes = nil)
6
+ size = determine_alternative_size_for(alternative_sizes) || size
7
+
8
+ size, base_resolution = size.to_s.split('@')
9
+ base_resolution ||= Artwork.base_resolution
10
+
6
11
  desired_thumb = Thumbnail.new(size)
7
12
  matching_thumb_name = nil
8
13
 
14
+ ratio_for_current_resolution = base_resolution.to_f / Artwork.current_resolution.to_f
15
+
9
16
  if desired_thumb.compatible?
10
17
  desired_size = desired_thumb.width / ratio_for_current_resolution
11
18
 
@@ -42,7 +49,7 @@ module Artwork
42
49
  end
43
50
 
44
51
  def artwork_url(attachment_name, size, options = {})
45
- thumb_name = artwork_thumb_for(attachment_name, size)
52
+ thumb_name = artwork_thumb_for(attachment_name, size, options)
46
53
  send(attachment_name).url(thumb_name, options)
47
54
  end
48
55
 
@@ -52,8 +59,14 @@ module Artwork
52
59
 
53
60
  private
54
61
 
55
- def ratio_for_current_resolution
56
- Artwork.default_resolution.to_f / Artwork.current_resolution.to_f
62
+ def determine_alternative_size_for(alternative_sizes)
63
+ return unless alternative_sizes
64
+
65
+ new_size_definition = alternative_sizes \
66
+ .sort_by { |max_resolution, size| max_resolution } \
67
+ .find { |max_resolution, size| Artwork.actual_resolution <= max_resolution }
68
+
69
+ new_size_definition.last if new_size_definition
57
70
  end
58
71
  end
59
72
  end
@@ -1,3 +1,3 @@
1
1
  module Artwork
2
- VERSION = '0.6.1'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -6,8 +6,9 @@ module Artwork
6
6
 
7
7
  before :each do
8
8
  [
9
- :default_resolution, :supported_resolutions_list,
10
- :current_resolution, :load_2x_images
9
+ :base_resolution, :supported_resolutions_list,
10
+ :current_resolution, :actual_resolution,
11
+ :load_2x_images,
11
12
  ].each do |key|
12
13
 
13
14
  Thread.current[key] = nil
@@ -15,7 +16,7 @@ module Artwork
15
16
  end
16
17
  end
17
18
 
18
- [:default_resolution, :supported_resolutions_list].each do |option_name|
19
+ [:base_resolution, :supported_resolutions_list].each do |option_name|
19
20
  describe "##{option_name}" do
20
21
  let(:default_value) { option_name == :supported_resolutions_list ? [1440] : 1440 }
21
22
  let(:custom_value) { option_name == :supported_resolutions_list ? [1024] : 1024 }
@@ -70,8 +71,8 @@ module Artwork
70
71
  end
71
72
 
72
73
  describe '#current_resolution' do
73
- it 'falls back to default_resolution' do
74
- expect(config).to receive(:default_resolution).and_return('default')
74
+ it 'falls back to base_resolution' do
75
+ expect(config).to receive(:base_resolution).and_return('default')
75
76
  expect(config.current_resolution).to eq 'default'
76
77
  end
77
78
  end
@@ -83,6 +84,20 @@ module Artwork
83
84
  end
84
85
  end
85
86
 
87
+ describe '#actual_resolution' do
88
+ it 'falls back to base_resolution' do
89
+ expect(config).to receive(:base_resolution).and_return('default')
90
+ expect(config.actual_resolution).to eq 'default'
91
+ end
92
+ end
93
+
94
+ describe '#actual_resolution=' do
95
+ it 'allows setting the current actual resolution' do
96
+ config.actual_resolution = 12345
97
+ expect(config.actual_resolution).to eq 12345
98
+ end
99
+ end
100
+
86
101
  describe '#reset_configuration' do
87
102
  it 'resets the current_resolution' do
88
103
  config.current_resolution = 'current'
@@ -90,7 +105,7 @@ module Artwork
90
105
 
91
106
  config.reset_configuration
92
107
 
93
- expect(config).to receive(:default_resolution).and_return('default')
108
+ expect(config).to receive(:base_resolution).and_return('default')
94
109
  expect(config.current_resolution).to eq 'default'
95
110
  end
96
111
 
@@ -109,17 +124,18 @@ module Artwork
109
124
  double :cookies => cookies_hash
110
125
  end
111
126
 
112
- it 'sets current_resolution and load_2x_images from request cookies' do
127
+ it 'sets current_resolution, actual_resolution and load_2x_images from request cookies' do
113
128
  config.supported_resolutions_list = [1000, 2000, 3000]
114
129
  config.configure_for make_request('_retina' => '1', '_width' => '2000')
115
130
 
116
131
  expect(config.current_resolution).to eq 2000
132
+ expect(config.actual_resolution).to eq 2000
117
133
  expect(config.load_2x_images?).to eq true
118
134
  end
119
135
 
120
136
  it 'sets the load_2x_images flag from the _retina cookie' do
121
137
  config.supported_resolutions_list = [1000, 2000, 3000]
122
- config.default_resolution = 1000
138
+ config.base_resolution = 1000
123
139
 
124
140
  config.configure_for make_request('_retina' => '0')
125
141
  expect(config.load_2x_images?).to eq false
@@ -128,26 +144,30 @@ module Artwork
128
144
  expect(config.load_2x_images?).to eq true
129
145
  end
130
146
 
131
- it 'picks only from the supported resolutions list' do
147
+ it 'picks only from the supported resolutions list but stores the actual resolution as well' do
132
148
  config.supported_resolutions_list = [1000, 2000, 3000]
133
149
 
134
150
  config.configure_for make_request('_width' => '1234')
135
151
  expect(config.current_resolution).to eq 2000
152
+ expect(config.actual_resolution).to eq 1234
136
153
 
137
154
  config.configure_for make_request('_width' => '234')
138
155
  expect(config.current_resolution).to eq 1000
156
+ expect(config.actual_resolution).to eq 234
139
157
 
140
158
  config.configure_for make_request('_width' => '10234')
141
159
  expect(config.current_resolution).to eq 3000
160
+ expect(config.actual_resolution).to eq 10234
142
161
  end
143
162
 
144
- it 'falls back to default_resolution if no _width cookie' do
163
+ it 'falls back to base_resolution if no _width cookie' do
145
164
  config.supported_resolutions_list = []
146
- config.default_resolution = 5000
165
+ config.base_resolution = 5000
147
166
 
148
167
  config.configure_for make_request
149
168
 
150
169
  expect(config.current_resolution).to eq 5000
170
+ expect(config.actual_resolution).to eq 5000
151
171
  end
152
172
  end
153
173
  end
@@ -59,7 +59,7 @@ module Artwork
59
59
 
60
60
  describe '#artwork_url' do
61
61
  it 'returns the computed url of an attachment by delegating to artwork_thumb_for' do
62
- expect(instance).to receive(:artwork_thumb_for).with(:photo, :size).and_return(:computed_size)
62
+ expect(instance).to receive(:artwork_thumb_for).with(:photo, :size, 'options').and_return(:computed_size)
63
63
 
64
64
  attachment = double
65
65
  expect(attachment).to receive(:url).with(:computed_size, 'options').and_return 'some/url'
@@ -69,7 +69,7 @@ module Artwork
69
69
  end
70
70
 
71
71
  it 'works with two arguments and a hash options' do
72
- expect(instance).to receive(:artwork_thumb_for).with(:photo, :size).and_return(:computed_size)
72
+ expect(instance).to receive(:artwork_thumb_for).with(:photo, :size, :some => 'options').and_return(:computed_size)
73
73
 
74
74
  attachment = double
75
75
  expect(attachment).to receive(:url).with(:computed_size, :some => 'options').and_return 'some/url'
@@ -79,7 +79,7 @@ module Artwork
79
79
  end
80
80
 
81
81
  it 'works with two arguments only without any options hash' do
82
- expect(instance).to receive(:artwork_thumb_for).with(:photo, :size).and_return(:computed_size)
82
+ expect(instance).to receive(:artwork_thumb_for).with(:photo, :size, {}).and_return(:computed_size)
83
83
 
84
84
  attachment = double
85
85
  expect(attachment).to receive(:url).with(:computed_size, {}).and_return 'some/url'
@@ -91,13 +91,14 @@ module Artwork
91
91
 
92
92
  describe '#artwork_thumb_for' do
93
93
  before :each do
94
- Artwork.default_resolution = 1000
94
+ Artwork.base_resolution = 1000
95
95
  Artwork.current_resolution = 1000
96
+ Artwork.actual_resolution = 1000
96
97
  Artwork.load_2x_images = false
97
98
  end
98
99
 
99
100
  def expect_thumb(size, expected)
100
- expect(instance.artwork_thumb_for(:image, size)).to eq expected
101
+ expect(instance.artwork_thumb_for(:image, *Array(size))).to eq expected
101
102
  end
102
103
 
103
104
  it 'picks the exact requested size if it exists' do
@@ -110,7 +111,7 @@ module Artwork
110
111
  end
111
112
 
112
113
  it 'scales the required size according to current_resolution' do
113
- Artwork.default_resolution = 1000
114
+ Artwork.base_resolution = 1000
114
115
  Artwork.current_resolution = 2000
115
116
 
116
117
  expect_thumb '1000x', :'2000x'
@@ -136,7 +137,7 @@ module Artwork
136
137
  expect_thumb 'unsupported', :unsupported
137
138
 
138
139
  Artwork.load_2x_images = true
139
- Artwork.default_resolution = 1000
140
+ Artwork.base_resolution = 1000
140
141
  Artwork.current_resolution = 5000
141
142
 
142
143
  expect_thumb 'unsupported', :unsupported
@@ -161,6 +162,18 @@ module Artwork
161
162
  expect_thumb '200x_some_label', :'320x_some_label'
162
163
  end
163
164
 
165
+ it 'allows changing the base resolution per request' do
166
+ Artwork.current_resolution = 2000
167
+
168
+ expect_thumb '320x@320', :'2000x'
169
+ expect_thumb '320x@640', :'1280x'
170
+
171
+ Artwork.current_resolution = 320
172
+ expect_thumb '320x@320', :'320x'
173
+ expect_thumb '320x_some_label@320', :'320x_some_label'
174
+ expect_thumb '200x_some_label@320', :'320x_some_label'
175
+ end
176
+
164
177
  it 'considers the aspect ratio of the desired thumb' do
165
178
  expect_thumb '320x499', :'320x500'
166
179
  expect_thumb '319x498', :'320x500'
@@ -190,6 +203,43 @@ module Artwork
190
203
  it 'returns nil if no thumbnail matches the requested label' do
191
204
  expect_thumb '319x_nonexistant_label', nil
192
205
  end
206
+
207
+ context 'with an alternative sizes definition' do
208
+ it 'ignores alternative sizes if current resolution is above all the max resolutions given' do
209
+ Artwork.current_resolution = 1000
210
+ Artwork.actual_resolution = 1000
211
+
212
+ expect_thumb ['320x', {700 => '100x@100'}], :'320x'
213
+ end
214
+
215
+ it 'picks the first alternative size if current resolution is smaller than all max resolutions' do
216
+ Artwork.current_resolution = 799
217
+ Artwork.actual_resolution = 799
218
+
219
+ expect_thumb ['320x', {1280 => '500x', 800 => '1000x'}], :'1280x'
220
+ end
221
+
222
+ it 'picks the first alternative size if current resolution is smaller than all max resolutions and supports custom base resolutions' do
223
+ Artwork.current_resolution = 799
224
+ Artwork.actual_resolution = 799
225
+
226
+ expect_thumb ['320x', {1280 => '50x@100', 800 => '100x@100'}], :'1280x'
227
+ end
228
+
229
+ it 'compares resolutions with <=' do
230
+ Artwork.current_resolution = 800
231
+ Artwork.actual_resolution = 800
232
+
233
+ expect_thumb ['320x', {1280 => '50x@100', 800 => '100x@100'}], :'1280x'
234
+ end
235
+
236
+ it 'picks the largest alternative size if current resolution is smaller only than the max resolution given' do
237
+ Artwork.current_resolution = 1200
238
+ Artwork.actual_resolution = 1200
239
+
240
+ expect_thumb ['320x', {1280 => '50x@100', 800 => '100x@100'}], :'640x'
241
+ end
242
+ end
193
243
  end
194
244
  end
195
245
  end
@@ -19,8 +19,32 @@ module Artwork
19
19
  end
20
20
  end
21
21
 
22
- it 'defines the artwork_tag helper method' do
23
- expect(View.instance_methods.map(&:to_sym)).to include(:artwork_tag)
22
+ describe '#artwork_tag' do
23
+ it 'is defined' do
24
+ expect(View.instance_methods.map(&:to_sym)).to include(:artwork_tag)
25
+ end
26
+
27
+ it 'returns an HTML img tag with the appropriate URL' do
28
+ record = double
29
+ expect(record).to receive(:artwork_url).with(:artwork_name, :size, {}).and_return('image_url')
30
+ allow(view_context).to receive(:content_tag).and_yield
31
+ expect(view_context).to receive(:image_tag).with('image_url', {:alt => nil}).and_return('image-tag-with-url')
32
+
33
+ generated_html = view_context.artwork_tag(record, :artwork_name, :size)
34
+
35
+ expect(generated_html).to eq 'image-tag-with-url'
36
+ end
37
+
38
+ it 'passes the options to artwork_url' do
39
+ record = double
40
+ expect(record).to receive(:artwork_url).with(:artwork_name, :size, {:some => 'options'}).and_return('image_url')
41
+ allow(view_context).to receive(:content_tag).and_yield
42
+ expect(view_context).to receive(:image_tag).with('image_url', {:alt => nil}).and_return('image-tag-with-url')
43
+
44
+ generated_html = view_context.artwork_tag(record, :artwork_name, :size, {:some => 'options'})
45
+
46
+ expect(generated_html).to eq 'image-tag-with-url'
47
+ end
24
48
  end
25
49
  end
26
50
  end
@@ -8,8 +8,8 @@ describe Artwork do
8
8
  it 'responds to configuration methods' do
9
9
  expect(Artwork).to respond_to(:configure_for)
10
10
  expect(Artwork).to respond_to(:reset_configuration)
11
- expect(Artwork).to respond_to(:default_resolution)
12
- expect(Artwork).to respond_to(:default_resolution=)
11
+ expect(Artwork).to respond_to(:base_resolution)
12
+ expect(Artwork).to respond_to(:base_resolution=)
13
13
  expect(Artwork).to respond_to(:supported_resolutions_list)
14
14
  expect(Artwork).to respond_to(:supported_resolutions_list=)
15
15
  expect(Artwork).to respond_to(:load_2x_images?)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: artwork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitar Dimitrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-15 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -104,6 +104,7 @@ extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
106
  - ".rspec"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md