administrate-field-paperclip 0.0.4 → 0.0.5

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: 162c10abe6072b045b87423a5fd00e5e94fbe9a7
4
- data.tar.gz: 767b3a4cd0a3cdd62eb926d9407378a04e6bb231
3
+ metadata.gz: 7e0b56ab237b19ed228a09087f2f0444ccdceb8f
4
+ data.tar.gz: bde43f8aa805c02351a333a135efbec1588e47f3
5
5
  SHA512:
6
- metadata.gz: '09960ab41b2c6c640ac8a26ca5dd5fc11b96e498773997392cd2d1a4a16b8fc324c8d7a75cf463ddbcb6b7769e7142b977361aa449c9b057de28f62f06db72fa'
7
- data.tar.gz: c2738783dd725243fedbcafff58971efcf8ea1e395363cfe8c1cdd41dd556f61f20541e51857f928cffc2fd4a55a690e43ab2d376d416b9ffe865006129e8f03
6
+ metadata.gz: b45a08d6cc7cd2054e6812a47390ce4cd59e1eac09c7e9adba2866d483a2cb16b65bcf1e9c58b2b96eb8ee4c07288a6c1d683f36e46e3185fdfff8180f03cba2
7
+ data.tar.gz: ba0435b9a6f21bf5b3149f9965f035c44e27efd9aa0e0dc71f75930cca940c76ab6b956f1dc138ed1d2932f7ffae9e0317a47b196758a41711df9a6c379c892a
data/.gitignore CHANGED
@@ -1,12 +1,12 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /*.gem
11
- /spec/processed_images/
12
- /.byebug_history
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /*.gem
11
+ /spec/processed_images/
12
+ /.byebug_history
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
@@ -1,19 +1,19 @@
1
- Rails:
2
- Enabled: true
3
-
4
- Metrics/LineLength:
5
- Max: 120
6
-
7
- Documentation:
8
- Enabled: false
9
-
10
- Style/FrozenStringLiteralComment:
11
- Enabled: false
12
-
13
- # specs tend to get long
14
- Metrics/BlockLength:
15
- Exclude:
16
- - 'spec/**/*'
17
-
18
- Style/TrailingCommaInLiteral:
19
- EnforcedStyleForMultiline: comma
1
+ Rails:
2
+ Enabled: true
3
+
4
+ Metrics/LineLength:
5
+ Max: 120
6
+
7
+ Documentation:
8
+ Enabled: false
9
+
10
+ Style/FrozenStringLiteralComment:
11
+ Enabled: false
12
+
13
+ # specs tend to get long
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - 'spec/**/*'
17
+
18
+ Style/TrailingCommaInLiteral:
19
+ EnforcedStyleForMultiline: comma
data/.simplecov CHANGED
@@ -1,11 +1,11 @@
1
- SimpleCov.start 'rails' do
2
- add_group 'app', 'app'
3
- add_group 'lib', 'lib'
4
-
5
- refuse_coverage_drop
6
-
7
- formatter SimpleCov::Formatter::MultiFormatter.new([
8
- SimpleCov::Formatter::HTMLFormatter,
9
- Coveralls::SimpleCov::Formatter
10
- ])
11
- end
1
+ SimpleCov.start 'rails' do
2
+ add_group 'app', 'app'
3
+ add_group 'lib', 'lib'
4
+
5
+ refuse_coverage_drop
6
+
7
+ formatter SimpleCov::Formatter::MultiFormatter.new([
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ])
11
+ end
@@ -1,14 +1,14 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.1
4
- - 2.3.3
5
- - 2.2.6
6
- - 2.1.10
7
- cache: bundler
8
- install: bundle install
9
- script:
10
- - bundle exec rubocop
11
- - bundle exec rspec
12
- matrix:
13
- allow_failures:
1
+ language: ruby
2
+ rvm:
3
+ - 2.4.1
4
+ - 2.3.3
5
+ - 2.2.6
6
+ - 2.1.10
7
+ cache: bundler
8
+ install: bundle install
9
+ script:
10
+ - bundle exec rubocop
11
+ - bundle exec rspec
12
+ matrix:
13
+ allow_failures:
14
14
  - rvm: 2.1.10
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2017 Fernando Briano
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Fernando Briano
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,45 +1,45 @@
1
- # Administrate::Field::Paperclip
2
-
3
- A plugin to integrate [Paperclip](https://github.com/thoughtbot/paperclip) fields in [Administrate](https://github.com/thoughtbot/administrate).
4
-
5
- # Instructions
6
-
7
- Add `administrate-field-paperclip` and `paperclip` to your Gemfile:
8
-
9
- ```
10
- gem 'administrate-field-paperclip'
11
- gem 'paperclip'
12
- ```
13
-
14
- Install:
15
-
16
- ```
17
- $ bundle install
18
- ```
19
-
20
- ## Usage
21
-
22
- Follow the [instructions on Paperclip](https://github.com/thoughtbot/paperclip#quick-start) to get started with your models and migrations. Once you've added the Paperclip attribute to your models, edit your Administrate dashboards. If you added 'avatar' to 'User', then you should:
23
-
24
- ```ruby
25
- class UserDashboard < Administrate::BaseDashboard
26
- ATTRIBUTE_TYPES = {
27
- avatar: Field::Paperclip,
28
- }
29
- # ...
30
- ```
31
-
32
- Then add `:avatar` to `FORM_ATTRIBUTES`, `SHOW_PAGE_ATTRIBUTES` and (optionally) `COLLECTION_ATTRIBUTES`.
33
-
34
- You can provide the field with options using `Field::Paperclip.with_options(options)`:
35
-
36
- * `thumbnail_style` (defaults to `'thumbnail'`) to control what image style is used to display the image in collection views
37
- * `big_style` (defaults to `'original'`) to control what image style is used to display the image on the show page.
38
- * `url_only` (defaults to `false`) to show only a URL (as a link) instead of trying to display an image.
39
-
40
- ## [Contributors](https://github.com/picandocodigo/administrate-field-paperclip/graphs/contributors)
41
-
42
- * Klas Eskilson - https://github.com/klaseskilson
43
- * Rich - https://github.com/pedantic-git
44
-
45
- Based on the [Administrate::Field::Image](https://github.com/thoughtbot/administrate-field-image) template.
1
+ # Administrate::Field::Paperclip
2
+
3
+ A plugin to integrate [Paperclip](https://github.com/thoughtbot/paperclip) fields in [Administrate](https://github.com/thoughtbot/administrate).
4
+
5
+ # Instructions
6
+
7
+ Add `administrate-field-paperclip` and `paperclip` to your Gemfile:
8
+
9
+ ```
10
+ gem 'administrate-field-paperclip'
11
+ gem 'paperclip'
12
+ ```
13
+
14
+ Install:
15
+
16
+ ```
17
+ $ bundle install
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Follow the [instructions on Paperclip](https://github.com/thoughtbot/paperclip#quick-start) to get started with your models and migrations. Once you've added the Paperclip attribute to your models, edit your Administrate dashboards. If you added 'avatar' to 'User', then you should:
23
+
24
+ ```ruby
25
+ class UserDashboard < Administrate::BaseDashboard
26
+ ATTRIBUTE_TYPES = {
27
+ avatar: Field::Paperclip,
28
+ }
29
+ # ...
30
+ ```
31
+
32
+ Then add `:avatar` to `FORM_ATTRIBUTES`, `SHOW_PAGE_ATTRIBUTES` and (optionally) `COLLECTION_ATTRIBUTES`.
33
+
34
+ You can provide the field with options using `Field::Paperclip.with_options(options)`:
35
+
36
+ * `thumbnail_style` (defaults to `'thumbnail'`) to control what image style is used to display the image in collection views
37
+ * `big_style` (defaults to `'original'`) to control what image style is used to display the image on the show page.
38
+ * `url_only` (defaults to `false`) to show only a URL (as a link) instead of trying to display an image.
39
+
40
+ ## [Contributors](https://github.com/picandocodigo/administrate-field-paperclip/graphs/contributors)
41
+
42
+ * Klas Eskilson - https://github.com/klaseskilson
43
+ * Rich - https://github.com/pedantic-git
44
+
45
+ Based on the [Administrate::Field::Image](https://github.com/thoughtbot/administrate-field-image) template.
data/Rakefile CHANGED
@@ -1,21 +1,20 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
-
8
- require 'bundler/gem_tasks'
9
-
10
- ##
11
- # Configure the test suite.
12
- ##
13
- require 'rspec/core'
14
- require 'rspec/core/rake_task'
15
-
16
- RSpec::Core::RakeTask.new
17
-
18
- ##
19
- # By default, just run the tests.
20
- ##
21
- task default: :spec
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'bundler/gem_tasks'
8
+
9
+ ##
10
+ # Configure the test suite.
11
+ ##
12
+ require 'rspec/core'
13
+ require 'rspec/core/rake_task'
14
+
15
+ RSpec::Core::RakeTask.new
16
+
17
+ ##
18
+ # By default, just run the tests.
19
+ ##
20
+ task default: :spec
@@ -1,29 +1,29 @@
1
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
-
3
- Gem::Specification.new do |gem|
4
- gem.name = 'administrate-field-paperclip'
5
- gem.version = '0.0.4'
6
- gem.authors = ['Fernando Briano']
7
- gem.email = ['fernando@picandocodigo.net']
8
- gem.homepage = 'https://github.com/picandocodigo/administrate-field-paperclip'
9
- gem.summary = 'Paperclip field plugin for Administrate'
10
- gem.description = 'Integrates Paperclip as a field for Administrate in Rails apps'
11
- gem.license = 'MIT'
12
-
13
- gem.require_paths = ['lib']
14
- gem.files = `git ls-files`.split("\n")
15
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split('\n')
16
-
17
- gem.add_dependency 'administrate', '~> 0.4'
18
- gem.add_dependency 'rails', '>= 4.2', '< 5.1'
19
-
20
- gem.add_development_dependency 'byebug'
21
- gem.add_development_dependency 'factory_girl'
22
- gem.add_development_dependency 'fog'
23
- gem.add_development_dependency 'paperclip'
24
- gem.add_development_dependency 'sqlite3'
25
- gem.add_development_dependency 'coveralls'
26
- gem.add_development_dependency 'rspec', '~> 3.5'
27
- gem.add_development_dependency 'rubocop'
28
- gem.add_development_dependency 'simplecov'
29
- end
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = 'administrate-field-paperclip'
5
+ gem.version = '0.0.5'
6
+ gem.authors = ['Fernando Briano']
7
+ gem.email = ['fernando@picandocodigo.net']
8
+ gem.homepage = 'https://github.com/picandocodigo/administrate-field-paperclip'
9
+ gem.summary = 'Paperclip field plugin for Administrate'
10
+ gem.description = 'Integrates Paperclip as a field for Administrate in Rails apps'
11
+ gem.license = 'MIT'
12
+
13
+ gem.require_paths = ['lib']
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split('\n')
16
+
17
+ gem.add_dependency 'administrate', '~> 0.4'
18
+ gem.add_dependency 'rails', '>= 4.2', '< 6'
19
+
20
+ gem.add_development_dependency 'byebug'
21
+ gem.add_development_dependency 'factory_girl'
22
+ gem.add_development_dependency 'fog'
23
+ gem.add_development_dependency 'paperclip'
24
+ gem.add_development_dependency 'sqlite3'
25
+ gem.add_development_dependency 'coveralls'
26
+ gem.add_development_dependency 'rspec', '~> 3.5'
27
+ gem.add_development_dependency 'rubocop'
28
+ gem.add_development_dependency 'simplecov'
29
+ end
@@ -1,5 +1,5 @@
1
- <% if field.url_only? -%>
2
- <%= link_to field.url, field.url if field.url.present? %>
3
- <% else -%>
4
- <%= image_tag field.thumbnail %>
5
- <% end -%>
1
+ <% if field.url_only? -%>
2
+ <%= link_to field.url, field.url if field.url.present? %>
3
+ <% else -%>
4
+ <%= image_tag field.thumbnail %>
5
+ <% end -%>
@@ -1,5 +1,5 @@
1
- <% if field.url_only? -%>
2
- <%= link_to field.url, field.url if field.url.present? %>
3
- <% else -%>
4
- <%= image_tag field.url if field.url.present? %>
5
- <% end -%>
1
+ <% if field.url_only? -%>
2
+ <%= link_to field.url, field.url if field.url.present? %>
3
+ <% else -%>
4
+ <%= image_tag field.url if field.url.present? %>
5
+ <% end -%>
@@ -1,41 +1,41 @@
1
- require 'administrate/field/base'
2
- require 'rails'
3
-
4
- module Administrate
5
- module Field
6
- class Paperclip < Administrate::Field::Base
7
- class Engine < ::Rails::Engine
8
- end
9
-
10
- def style(size = big_style)
11
- data.try(:url, size) || ''
12
- end
13
-
14
- delegate :url, to: :data
15
-
16
- def thumbnail
17
- style(thumbnail_style)
18
- end
19
-
20
- # Just display the URL as a link, rather than trying to make it an image
21
- def url_only?
22
- options.fetch(:url_only, false)
23
- end
24
-
25
- alias url style
26
-
27
- private
28
-
29
- DEFAULT_THUMBNAIL_STYLE = :thumbnail
30
- DEFAULT_BIG_STYLE = :original
31
-
32
- def thumbnail_style
33
- options.fetch(:thumbnail_style, DEFAULT_THUMBNAIL_STYLE)
34
- end
35
-
36
- def big_style
37
- options.fetch(:big_style, DEFAULT_BIG_STYLE)
38
- end
39
- end
40
- end
41
- end
1
+ require 'administrate/field/base'
2
+ require 'rails'
3
+
4
+ module Administrate
5
+ module Field
6
+ class Paperclip < Administrate::Field::Base
7
+ class Engine < ::Rails::Engine
8
+ end
9
+
10
+ def style(size = big_style)
11
+ data.try(:url, size) || ''
12
+ end
13
+
14
+ delegate :url, to: :data
15
+
16
+ def thumbnail
17
+ style(thumbnail_style)
18
+ end
19
+
20
+ # Just display the URL as a link, rather than trying to make it an image
21
+ def url_only?
22
+ options.fetch(:url_only, false)
23
+ end
24
+
25
+ alias url style
26
+
27
+ private
28
+
29
+ DEFAULT_THUMBNAIL_STYLE = :thumbnail
30
+ DEFAULT_BIG_STYLE = :original
31
+
32
+ def thumbnail_style
33
+ options.fetch(:thumbnail_style, DEFAULT_THUMBNAIL_STYLE)
34
+ end
35
+
36
+ def big_style
37
+ options.fetch(:big_style, DEFAULT_BIG_STYLE)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
- FactoryGirl.define do
2
- factory :post do
3
- image { File.new(File.join('spec', 'fixtures', 'image.png')) }
4
- end
5
- end
1
+ FactoryGirl.define do
2
+ factory :post do
3
+ image { File.new(File.join('spec', 'fixtures', 'image.png')) }
4
+ end
5
+ end
@@ -1,12 +1,15 @@
1
- class Post < ActiveRecord::Base
2
- include Paperclip::Glue
3
-
4
- has_attached_file :image,
5
- styles: {
6
- thumbnail: '4x4#',
7
- extra: '2x4>',
8
- }
9
-
10
- # validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
11
- do_not_validate_attachment_file_type :image
12
- end
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
4
+ class Post < ApplicationRecord
5
+ include Paperclip::Glue
6
+
7
+ has_attached_file :image,
8
+ styles: {
9
+ thumbnail: '4x4#',
10
+ extra: '2x4>',
11
+ }
12
+
13
+ # validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
14
+ do_not_validate_attachment_file_type :image
15
+ end
@@ -1,78 +1,78 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Administrate::Field::Paperclip do
4
- let(:post) { create(:post) }
5
- let(:page) { :show }
6
- let(:field) { described_class.new(:image, post.image, page) }
7
- let(:empty_field) { described_class.new(:image, nil, page) }
8
-
9
- require 'administrate/field/paperclip'
10
-
11
- describe '#to_partial_path' do
12
- it 'returns a partial based on the page being rendered' do
13
- expect(empty_field.to_partial_path).to eq("/fields/paperclip/#{page}")
14
- end
15
- end
16
-
17
- PAPECLIP_FIELD_METHODS = %w(style thumbnail url).freeze
18
- PAPECLIP_FIELD_METHODS.each do |method|
19
- describe "##{method}" do
20
- context 'when inner_attribute is not set' do
21
- it 'should return a non-nil url' do
22
- expect(field.send(method)).to_not eq ''
23
- end
24
- end
25
-
26
- context 'when image attachment doesn\'t exist' do
27
- it 'should return empty string' do
28
- expect(empty_field.send(method)).to eq ''
29
- end
30
- end
31
- end
32
- end
33
-
34
- describe '#thumbnail' do
35
- context 'when thumbnail size is provided as an option' do
36
- let(:field) { described_class.new(:image, post.image, page, thumbnail_style: :extra) }
37
-
38
- it 'should return a string to the correct image' do
39
- expect(field.thumbnail).to_not be_nil
40
- expect(field.thumbnail).to include('extra')
41
- end
42
- end
43
- end
44
-
45
- describe '#style' do
46
- context 'when big image style is provided as an option' do
47
- let(:field) { described_class.new(:image, post.image, page, big_style: :extra) }
48
-
49
- it 'should return a string to the correct image' do
50
- expect(field.style).to_not be_nil
51
- expect(field.style).to include('extra')
52
- end
53
- end
54
-
55
- context 'when image style is provided as a parameter' do
56
- let(:field) { described_class.new(:image, post.image, page) }
57
-
58
- it 'should return a string to the correct image' do
59
- expect(field.style(:extra)).to_not be_nil
60
- expect(field.style(:extra)).to include('extra')
61
- end
62
- end
63
- end
64
-
65
- describe '#url_only?' do
66
- context 'with no options' do
67
- it 'should be false' do
68
- expect(field.url_only?).to be false
69
- end
70
- end
71
- context 'with url_only option true' do
72
- let(:field) { described_class.new(:image, post.image, page, url_only: true) }
73
- it 'should be true' do
74
- expect(field.url_only?).to be true
75
- end
76
- end
77
- end
78
- end
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Administrate::Field::Paperclip do
4
+ let(:post) { create(:post) }
5
+ let(:page) { :show }
6
+ let(:field) { described_class.new(:image, post.image, page) }
7
+ let(:empty_field) { described_class.new(:image, nil, page) }
8
+
9
+ require 'administrate/field/paperclip'
10
+
11
+ describe '#to_partial_path' do
12
+ it 'returns a partial based on the page being rendered' do
13
+ expect(empty_field.to_partial_path).to eq("/fields/paperclip/#{page}")
14
+ end
15
+ end
16
+
17
+ PAPECLIP_FIELD_METHODS = %w[style thumbnail url].freeze
18
+ PAPECLIP_FIELD_METHODS.each do |method|
19
+ describe "##{method}" do
20
+ context 'when inner_attribute is not set' do
21
+ it 'should return a non-nil url' do
22
+ expect(field.send(method)).to_not eq ''
23
+ end
24
+ end
25
+
26
+ context 'when image attachment doesn\'t exist' do
27
+ it 'should return empty string' do
28
+ expect(empty_field.send(method)).to eq ''
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ describe '#thumbnail' do
35
+ context 'when thumbnail size is provided as an option' do
36
+ let(:field) { described_class.new(:image, post.image, page, thumbnail_style: :extra) }
37
+
38
+ it 'should return a string to the correct image' do
39
+ expect(field.thumbnail).to_not be_nil
40
+ expect(field.thumbnail).to include('extra')
41
+ end
42
+ end
43
+ end
44
+
45
+ describe '#style' do
46
+ context 'when big image style is provided as an option' do
47
+ let(:field) { described_class.new(:image, post.image, page, big_style: :extra) }
48
+
49
+ it 'should return a string to the correct image' do
50
+ expect(field.style).to_not be_nil
51
+ expect(field.style).to include('extra')
52
+ end
53
+ end
54
+
55
+ context 'when image style is provided as a parameter' do
56
+ let(:field) { described_class.new(:image, post.image, page) }
57
+
58
+ it 'should return a string to the correct image' do
59
+ expect(field.style(:extra)).to_not be_nil
60
+ expect(field.style(:extra)).to include('extra')
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '#url_only?' do
66
+ context 'with no options' do
67
+ it 'should be false' do
68
+ expect(field.url_only?).to be false
69
+ end
70
+ end
71
+ context 'with url_only option true' do
72
+ let(:field) { described_class.new(:image, post.image, page, url_only: true) }
73
+ it 'should be true' do
74
+ expect(field.url_only?).to be true
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,11 +1,11 @@
1
- # make sure we have paperclip here
2
- require 'paperclip'
3
-
4
- include Paperclip::Schema
5
- ActiveRecord::Schema.define do
6
- self.verbose = false
7
-
8
- create_table :posts, force: true do |t|
9
- t.attachment :image
10
- end
11
- end
1
+ # make sure we have paperclip here
2
+ require 'paperclip'
3
+
4
+ include Paperclip::Schema
5
+ ActiveRecord::Schema.define do
6
+ self.verbose = false
7
+
8
+ create_table :posts, force: true do |t|
9
+ t.attachment :image
10
+ end
11
+ end
@@ -1,37 +1,37 @@
1
- # start coverage tracking
2
- require 'coveralls'
3
- require 'simplecov'
4
- SimpleCov.start
5
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6
- require 'administrate/field/paperclip'
7
- # config Paperclip for testing purposes
8
- require 'paperclip'
9
- require 'fog'
10
- Paperclip::Attachment.default_options[:storage] = :fog
11
- Paperclip::Attachment.default_options[:fog_credentials] = {
12
- provider: 'Local',
13
- local_root: File.join(__FILE__, '../processed_images'),
14
- }
15
- Paperclip::Attachment.default_options[:fog_directory] = ''
16
- Paperclip::Attachment.default_options[:fog_host] = 'http://localhost:3000'
17
-
18
- # enable debugging using byebug
19
- require 'byebug'
20
-
21
- # start up factory_girl
22
- require 'factory_girl'
23
-
24
- # start db and load migrations and everything
25
- require 'active_record'
26
- ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
27
- require_relative 'schema'
28
- require_relative 'models'
29
-
30
- # config rspec
31
- RSpec.configure do |config|
32
- # configure factory girl
33
- config.include FactoryGirl::Syntax::Methods
34
- config.before(:suite) do
35
- FactoryGirl.find_definitions
36
- end
37
- end
1
+ # start coverage tracking
2
+ require 'coveralls'
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6
+ require 'administrate/field/paperclip'
7
+ # config Paperclip for testing purposes
8
+ require 'paperclip'
9
+ require 'fog'
10
+ Paperclip::Attachment.default_options[:storage] = :fog
11
+ Paperclip::Attachment.default_options[:fog_credentials] = {
12
+ provider: 'Local',
13
+ local_root: File.join(__FILE__, '../processed_images'),
14
+ }
15
+ Paperclip::Attachment.default_options[:fog_directory] = ''
16
+ Paperclip::Attachment.default_options[:fog_host] = 'http://localhost:3000'
17
+
18
+ # enable debugging using byebug
19
+ require 'byebug'
20
+
21
+ # start up factory_girl
22
+ require 'factory_girl'
23
+
24
+ # start db and load migrations and everything
25
+ require 'active_record'
26
+ ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
27
+ require_relative 'schema'
28
+ require_relative 'models'
29
+
30
+ # config rspec
31
+ RSpec.configure do |config|
32
+ # configure factory girl
33
+ config.include FactoryGirl::Syntax::Methods
34
+ config.before(:suite) do
35
+ FactoryGirl.find_definitions
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-paperclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Briano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-23 00:00:00.000000000 Z
11
+ date: 2017-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '4.2'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '5.1'
36
+ version: '6'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '4.2'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '5.1'
46
+ version: '6'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: byebug
49
49
  requirement: !ruby/object:Gem::Requirement