attachy 0.3.0 → 0.4.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: 4e9241e9c38f8908e41f4da86a410f764bdc2c69
4
- data.tar.gz: 14199b9548d9491c0044f21ee902637de1764931
3
+ metadata.gz: ba799d1c72c52b5e44034d297788610c44d4f123
4
+ data.tar.gz: 5797413a3e7f89ccdfb541e0852527c5f40d86aa
5
5
  SHA512:
6
- metadata.gz: 5d852cbf8fd70d95d8c087996194c76bfd654bbab585d92f0e7b1f92125d3e20259b6bdddc5a121c6d34214674c26fb307a5b850ee81d7db5d2eb966e730e775
7
- data.tar.gz: bb39b46cfbec749ee7828ee7c096327fbe22023dcbedf96da28cbb9a1d52695e87c3ee0f7440de9fb87d56a2bbe6a54f5de626e54f85ac9057c5100ba9798b1b
6
+ metadata.gz: 594a1d513a5f0b412d326915b990a668f4b119f3cf6bde2d038aae588190bab585285cf92cb77e6508b6f075c69ac2493b922e848b4ac7a9a7dd71afd760e276
7
+ data.tar.gz: 924c8edbedcf1091852f4aa227e8b91524627d9f43580781a41481d35bfaae30a47aa342d4932deb978830487c9224d70454b57981653fe9b6b7f8436b266272
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.4.0
2
+
3
+ - Default image is returned only if you declare it on `attacy.yml`.
4
+
1
5
  # 0.3.0
2
6
 
3
7
  - Fix deprecate warning for `class_name` on Rails 5.1.
@@ -41,7 +41,11 @@ module Attachy
41
41
  end
42
42
 
43
43
  def self.default
44
- new config['default']['image']
44
+ image = config.dig('default', 'image')
45
+
46
+ return if image.nil?
47
+
48
+ new image
45
49
  end
46
50
 
47
51
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Attachy
4
- VERSION = '0.3.0'.freeze
4
+ VERSION = '0.4.0'.freeze
5
5
  end
@@ -3,26 +3,46 @@
3
3
  require 'rails_helper'
4
4
 
5
5
  RSpec.describe Attachy::File, '#default' do
6
- before do
7
- allow(::Rails).to receive_message_chain(:application, :config_for).with(:attachy) do
8
- {
9
- 'default' => {
10
- 'image' => {
11
- 'public_id' => 'default',
12
- 'format' => 'png',
13
- 'version' => 1
6
+ context 'when default image is present' do
7
+ before do
8
+ allow(::Rails).to receive_message_chain(:application, :config_for).with(:attachy) do
9
+ {
10
+ 'default' => {
11
+ 'image' => {
12
+ 'public_id' => 'default',
13
+ 'format' => 'png',
14
+ 'version' => 1
15
+ }
14
16
  }
15
17
  }
16
- }
18
+ end
17
19
  end
20
+
21
+ it 'returns a new file object with the config values' do
22
+ default = described_class.default
23
+
24
+ expect(default).to be_new_record
25
+ expect(default.format).to eq 'png'
26
+ expect(default.public_id).to eq 'default'
27
+ expect(default.version).to eq '1'
28
+ end
29
+ end
30
+
31
+ context 'when default image is not present' do
32
+ before do
33
+ allow(::Rails).to receive_message_chain(:application, :config_for).with(:attachy) do
34
+ { 'default' => {} }
35
+ end
36
+ end
37
+
38
+ specify { expect(described_class.default).to eq nil }
18
39
  end
19
40
 
20
- it 'returns a new file object with the config values' do
21
- default = described_class.default
41
+ context 'when default image is not present' do
42
+ before do
43
+ allow(::Rails).to receive_message_chain(:application, :config_for).with(:attachy) { {} }
44
+ end
22
45
 
23
- expect(default).to be_new_record
24
- expect(default.format).to eq 'png'
25
- expect(default.public_id).to eq 'default'
26
- expect(default.version).to eq '1'
46
+ specify { expect(described_class.default).to eq nil }
27
47
  end
28
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-30 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cloudinary
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  version: '0'
255
255
  requirements: []
256
256
  rubyforge_project:
257
- rubygems_version: 2.6.11
257
+ rubygems_version: 2.6.14
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: Attachments handler for Rails via Cloudinary.