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 +4 -4
- data/CHANGELOG.md +4 -0
- data/carrierwave-base64.gemspec +2 -0
- data/lib/carrierwave/base64/adapter.rb +5 -1
- data/lib/carrierwave/base64/version.rb +1 -1
- data/spec/adapter_spec.rb +12 -1
- data/spec/spec_helper.rb +6 -1
- data/spec/support/models.rb +4 -0
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43ded0d0612bfca0092a8f69bf75f2cea936c1d2
|
4
|
+
data.tar.gz: 4ade936bbe6f44cc7e25e5aac7f34cc11a6866fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502a3d71f3829b95dd92f47b1079e338976189ecf448a1c1c5a680b927f267006a3bc084a376d27f9deb7910a0971f29c3e2ab32a8464a389e70144129b3fdef
|
7
|
+
data.tar.gz: 7c18f72082d986903560a01c20ff51e6e04fb5afc6e03054e7e3535e3e0a806d7e7158063c1509d5a54f30f13b71a34a3c2fef99d63f04a1b46defada8cc54a4
|
data/CHANGELOG.md
CHANGED
@@ -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)
|
data/carrierwave-base64.gemspec
CHANGED
@@ -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
|
-
|
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
|
data/spec/adapter_spec.rb
CHANGED
@@ -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
|
data/spec/spec_helper.rb
CHANGED
@@ -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
|
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'
|
data/spec/support/models.rb
CHANGED
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
|
+
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:
|
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.
|
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.
|