carrierwave-base64 2.3.4 → 2.3.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: c51cad701a3c7e8051997d469afb8cf49b546409
4
- data.tar.gz: 653308f4522090cd60e8f6c522fc73c608b9361d
3
+ metadata.gz: 43ded0d0612bfca0092a8f69bf75f2cea936c1d2
4
+ data.tar.gz: 4ade936bbe6f44cc7e25e5aac7f34cc11a6866fe
5
5
  SHA512:
6
- metadata.gz: 03ef9d8787dea43e25ee9a563c7cb0711fe6126ee655fc9a23198d1ba89fdc45cdde6cabac79e357576cf9b3479d5b0c26e710abe5c3ecc37aa89b6d4ba65212
7
- data.tar.gz: 60f319ef16802348c20f474a9fa718ed8192f8f1db772d53cdd071b13f2bd23a4c4c674c118ab5d7cba4175a4f98236d1a34bd3b53109ca6c4cc0728866a004e
6
+ metadata.gz: 502a3d71f3829b95dd92f47b1079e338976189ecf448a1c1c5a680b927f267006a3bc084a376d27f9deb7910a0971f29c3e2ab32a8464a389e70144129b3fdef
7
+ data.tar.gz: 7c18f72082d986903560a01c20ff51e6e04fb5afc6e03054e7e3535e3e0a806d7e7158063c1509d5a54f30f13b71a34a3c2fef99d63f04a1b46defada8cc54a4
@@ -1,5 +1,9 @@
1
1
  # carrierwave-base64 changelog
2
2
 
3
+ ## 2.3.5
4
+
5
+ - Fixed issue with mongoid models, when `attribute_will_change!` method was called, that wasn't defined in Mongoid models (credits to @cuongnm53)
6
+
3
7
  ## 2.3.3
4
8
 
5
9
  - Added proc support for the `:file_name` option for the `mount_base64_uploader` method. (credits to @hendricius)
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_development_dependency 'rails', '>= 3.2.0'
26
26
  spec.add_development_dependency 'sqlite3'
27
+ spec.add_development_dependency 'mongoid'
28
+ spec.add_development_dependency 'carrierwave-mongoid'
27
29
  spec.add_development_dependency 'bundler', '~> 1.7'
28
30
  spec.add_development_dependency 'rake', ['~> 10.0']
29
31
  spec.add_development_dependency 'rspec', ['~> 2.14']
@@ -1,11 +1,14 @@
1
1
  module Carrierwave
2
2
  module Base64
3
3
  module Adapter
4
+ # rubocop:disable Metrics/MethodLength
4
5
  def mount_base64_uploader(attribute, uploader_class, options = {})
5
6
  mount_uploader attribute, uploader_class, options
6
7
 
7
8
  define_method "#{attribute}=" do |data|
8
- send "#{attribute}_will_change!" if data.present?
9
+ if respond_to?("#{attribute}_will_change!") && data.present?
10
+ send "#{attribute}_will_change!"
11
+ end
9
12
 
10
13
  return super(data) unless data.is_a?(String) &&
11
14
  data.strip.start_with?('data')
@@ -14,6 +17,7 @@ module Carrierwave
14
17
  data.strip, options[:file_name] || 'file'
15
18
  ))
16
19
  end
20
+ # rubocop:enable Metrics/MethodLength
17
21
  end
18
22
  end
19
23
  end
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Base64
3
- VERSION = '2.3.4'.freeze
3
+ VERSION = '2.3.5'.freeze
4
4
  end
5
5
  end
@@ -7,6 +7,11 @@ RSpec.describe Carrierwave::Base64::Adapter do
7
7
  Post.new
8
8
  end
9
9
 
10
+ let(:mongoid_model) do
11
+ MongoidModel.mount_base64_uploader(:image, uploader)
12
+ MongoidModel.new
13
+ end
14
+
10
15
  it 'mounts the uploader on the image field' do
11
16
  expect(subject.image).to be_an_instance_of(uploader)
12
17
  end
@@ -20,7 +25,7 @@ RSpec.describe Carrierwave::Base64::Adapter do
20
25
  subject[:image] = 'test.jpg'
21
26
  end
22
27
 
23
- it 'sets will_change for the attribute' do
28
+ it 'sets will_change for the attribute on activerecord models' do
24
29
  expect(subject.changed?).to be_truthy
25
30
  end
26
31
 
@@ -53,6 +58,12 @@ RSpec.describe Carrierwave::Base64::Adapter do
53
58
  it 'sets will_change for the attribute' do
54
59
  expect(subject.changed?).to be_truthy
55
60
  end
61
+
62
+ it 'does not call will_change mongoid models' do
63
+ expect do
64
+ mongoid_model.image = 'test.jpg'
65
+ end.not_to raise_error
66
+ end
56
67
  end
57
68
 
58
69
  context 'stored uploads exist for the field' do
@@ -6,14 +6,19 @@ require 'sham_rack'
6
6
 
7
7
  require 'rails'
8
8
  require 'active_record'
9
+ require 'mongoid'
9
10
 
10
11
  require 'carrierwave'
11
12
  require 'carrierwave/orm/activerecord'
13
+ require 'carrierwave/mongoid'
12
14
 
13
15
  require 'carrierwave/base64'
14
16
 
15
17
  ActiveRecord::Base.raise_in_transactional_callbacks = true
16
- ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
18
+ ActiveRecord::Base.establish_connection(
19
+ adapter: 'sqlite3',
20
+ database: ':memory:'
21
+ )
17
22
 
18
23
  load 'support/schema.rb'
19
24
  require 'support/models'
@@ -1,2 +1,6 @@
1
1
  class Post < ActiveRecord::Base
2
2
  end
3
+
4
+ class MongoidModel
5
+ include Mongoid::Document
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-base64
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
4
+ version: 2.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Lebedev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-28 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mongoid
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: carrierwave-mongoid
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: bundler
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -185,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
213
  version: '0'
186
214
  requirements: []
187
215
  rubyforge_project:
188
- rubygems_version: 2.5.2
216
+ rubygems_version: 2.6.8
189
217
  signing_key:
190
218
  specification_version: 4
191
219
  summary: Upload images encoded as base64 to carrierwave.