carrierwave-cascade 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +1 -3
- data/carrierwave-cascade.gemspec +3 -3
- data/lib/carrierwave/cascade/version.rb +1 -1
- data/lib/carrierwave/storage/cascade.rb +4 -0
- data/spec/carrierwave-cascade_spec.rb +7 -4
- data/spec/carrierwave/storage/cascade_spec.rb +27 -20
- data/spec/spec_helper.rb +1 -1
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 159f531b71016527e29e57fea784ee76a842f375b6c158a4f1489b8696d1038f
|
4
|
+
data.tar.gz: f719f3ec25817acd89c4de01af9a524dd020280b6332995e7bf23d8858dcda4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd784ecc0cc1257ef1285d2f603bbdaa422c487e72052212f88e2b1a4bc6f11c452278fd4868875ad41c56bd304d497b01e670f6f85ca2c9c4b73a3e3515e6f3
|
7
|
+
data.tar.gz: fec7ae9c27d865687279bafafe715fd2311b19d1f345ec1a969d1f82205f596887a76b318663fdaac877a92811840f9d98965d79bd5ca6ebecc15d1c6361a7e3
|
data/.travis.yml
CHANGED
data/carrierwave-cascade.gemspec
CHANGED
@@ -27,8 +27,8 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency 'carrierwave', '>= 0.5.8'
|
29
29
|
|
30
|
-
spec.add_development_dependency "bundler"
|
30
|
+
spec.add_development_dependency "bundler"
|
31
31
|
spec.add_development_dependency "rake"
|
32
|
-
spec.add_development_dependency 'rspec', '~>
|
33
|
-
spec.add_development_dependency 'fog'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
spec.add_development_dependency 'fog-aws'
|
34
34
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CarrierWave::Uploader::Base do
|
4
|
-
it {
|
5
|
-
it {
|
6
|
-
it {
|
4
|
+
it { is_expected.to respond_to :primary_storage }
|
5
|
+
it { is_expected.to respond_to :secondary_storage }
|
6
|
+
it { is_expected.to respond_to :allow_secondary_file_deletion }
|
7
7
|
|
8
|
-
|
8
|
+
describe '#storage_engines' do
|
9
|
+
subject { super().storage_engines }
|
10
|
+
it { is_expected.to have_key :cascade }
|
11
|
+
end
|
9
12
|
end
|
@@ -14,25 +14,32 @@ describe CarrierWave::Storage::Cascade do
|
|
14
14
|
subject(:cascade){ CarrierWave::Storage::Cascade.new(uploader) }
|
15
15
|
|
16
16
|
describe "#initialize" do
|
17
|
-
|
18
|
-
|
17
|
+
describe '#primary_storage' do
|
18
|
+
subject { super().primary_storage }
|
19
|
+
it { is_expected.to be_a(CarrierWave::Storage::Fog)}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#secondary_storage' do
|
23
|
+
subject { super().secondary_storage }
|
24
|
+
it { is_expected.to be_a(CarrierWave::Storage::File)}
|
25
|
+
end
|
19
26
|
end
|
20
27
|
|
21
28
|
describe "#store!" do
|
22
29
|
let(:file){ CarrierWave::SanitizedFile.new("hello") }
|
23
30
|
|
24
31
|
before do
|
25
|
-
cascade.primary_storage.
|
26
|
-
cascade.secondary_storage.
|
32
|
+
allow(cascade.primary_storage).to receive_messages(:store! => file)
|
33
|
+
allow(cascade.secondary_storage).to receive_messages(:store! => file)
|
27
34
|
end
|
28
35
|
|
29
36
|
it "stores to the primary_storage" do
|
30
|
-
cascade.primary_storage.
|
37
|
+
expect(cascade.primary_storage).to receive(:store!).with(file)
|
31
38
|
cascade.store!(file)
|
32
39
|
end
|
33
40
|
|
34
41
|
it "does not store to the secondary_storage" do
|
35
|
-
cascade.secondary_storage.
|
42
|
+
expect(cascade.secondary_storage).not_to receive(:store!)
|
36
43
|
cascade.store!(file)
|
37
44
|
end
|
38
45
|
end
|
@@ -42,32 +49,32 @@ describe CarrierWave::Storage::Cascade do
|
|
42
49
|
let(:secondary_file){ CarrierWave::SanitizedFile.new("secondary") }
|
43
50
|
|
44
51
|
before do
|
45
|
-
cascade.primary_storage.
|
46
|
-
cascade.secondary_storage.
|
52
|
+
allow(cascade.primary_storage).to receive_messages(:retrieve! => primary_file)
|
53
|
+
allow(cascade.secondary_storage).to receive_messages(:retrieve! => secondary_file)
|
47
54
|
end
|
48
55
|
|
49
56
|
context "when file exists in primary_storage" do
|
50
57
|
before do
|
51
|
-
primary_file.
|
58
|
+
allow(primary_file).to receive_messages(:exists? => true)
|
52
59
|
end
|
53
60
|
|
54
61
|
context "when file exists in secondary_storage" do
|
55
62
|
before do
|
56
|
-
secondary_file.
|
63
|
+
allow(secondary_file).to receive_messages(:exists? => true)
|
57
64
|
end
|
58
65
|
|
59
66
|
it "returns the primary_file" do
|
60
|
-
cascade.retrieve!('file').
|
67
|
+
expect(cascade.retrieve!('file')).to eq(primary_file)
|
61
68
|
end
|
62
69
|
end
|
63
70
|
|
64
71
|
context "when file doesn't exist in secondary_storage" do
|
65
72
|
before do
|
66
|
-
secondary_file.
|
73
|
+
allow(secondary_file).to receive_messages(:exists? => false)
|
67
74
|
end
|
68
75
|
|
69
76
|
it "returns the primary_file" do
|
70
|
-
cascade.retrieve!('file').
|
77
|
+
expect(cascade.retrieve!('file')).to eq(primary_file)
|
71
78
|
end
|
72
79
|
end
|
73
80
|
|
@@ -75,15 +82,15 @@ describe CarrierWave::Storage::Cascade do
|
|
75
82
|
|
76
83
|
context "when file doesn't exist in primary_storage" do
|
77
84
|
before do
|
78
|
-
primary_file.
|
85
|
+
allow(primary_file).to receive_messages(:exists? => false)
|
79
86
|
end
|
80
87
|
|
81
88
|
it "returns a secondary_file proxy" do
|
82
|
-
cascade.retrieve!('file').
|
89
|
+
expect(cascade.retrieve!('file')).to be_a(CarrierWave::Storage::Cascade::SecondaryFileProxy)
|
83
90
|
end
|
84
91
|
|
85
92
|
it "returns a proxy to the real secondary_file" do
|
86
|
-
cascade.retrieve!('file').real_file.
|
93
|
+
expect(cascade.retrieve!('file').real_file).to eq(secondary_file)
|
87
94
|
end
|
88
95
|
|
89
96
|
end
|
@@ -104,13 +111,13 @@ describe CarrierWave::Storage::Cascade::SecondaryFileProxy do
|
|
104
111
|
end
|
105
112
|
|
106
113
|
it "delegates all methods to the real file" do
|
107
|
-
file.
|
114
|
+
expect(file).to receive(:foooooo)
|
108
115
|
cascade_file.foooooo
|
109
116
|
end
|
110
117
|
|
111
118
|
context "when allow_secondary_file_deletion is not set" do
|
112
119
|
it "doesn't delete the file" do
|
113
|
-
file.
|
120
|
+
expect(file).not_to receive(:delete)
|
114
121
|
cascade_file.delete
|
115
122
|
end
|
116
123
|
end
|
@@ -123,7 +130,7 @@ describe CarrierWave::Storage::Cascade::SecondaryFileProxy do
|
|
123
130
|
end
|
124
131
|
|
125
132
|
it "doesn't delete the file" do
|
126
|
-
file.
|
133
|
+
expect(file).not_to receive(:delete)
|
127
134
|
cascade_file.delete
|
128
135
|
end
|
129
136
|
end
|
@@ -136,7 +143,7 @@ describe CarrierWave::Storage::Cascade::SecondaryFileProxy do
|
|
136
143
|
end
|
137
144
|
|
138
145
|
it "does delete the file" do
|
139
|
-
file.
|
146
|
+
expect(file).to receive(:delete)
|
140
147
|
cascade_file.delete
|
141
148
|
end
|
142
149
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-cascade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Glowacz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.5.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.5.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '3.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '3.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: fog
|
70
|
+
name: fog-aws
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: "A storage plugin for carrierwave that will\n retrieving files from
|
@@ -91,8 +91,8 @@ executables: []
|
|
91
91
|
extensions: []
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
|
-
- .gitignore
|
95
|
-
- .travis.yml
|
94
|
+
- ".gitignore"
|
95
|
+
- ".travis.yml"
|
96
96
|
- Gemfile
|
97
97
|
- LICENSE.txt
|
98
98
|
- README.md
|
@@ -109,24 +109,23 @@ homepage: https://github.com/kjg/carrierwave-cascade
|
|
109
109
|
licenses:
|
110
110
|
- MIT
|
111
111
|
metadata: {}
|
112
|
-
post_install_message:
|
112
|
+
post_install_message:
|
113
113
|
rdoc_options: []
|
114
114
|
require_paths:
|
115
115
|
- lib
|
116
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
|
128
|
-
|
129
|
-
signing_key:
|
127
|
+
rubygems_version: 3.1.4
|
128
|
+
signing_key:
|
130
129
|
specification_version: 4
|
131
130
|
summary: Retrieve from a secondary storage when the file is not in the primary storage.
|
132
131
|
test_files:
|