carrierwave_reupload_fix 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
ADDED
@@ -41,8 +41,12 @@ module CarrierwaveReuploadFix
|
|
41
41
|
alias :original_update :update
|
42
42
|
|
43
43
|
def update(attributes)
|
44
|
-
original_update(attributes)
|
45
|
-
|
44
|
+
if original_update(attributes)
|
45
|
+
ReuploadFixer.new(self, VersionsRecreator.new, ExtensionsAssigner.new).fix
|
46
|
+
true
|
47
|
+
else
|
48
|
+
false
|
49
|
+
end
|
46
50
|
end
|
47
51
|
end
|
48
52
|
end
|
@@ -56,17 +56,43 @@ describe CarrierwaveReuploadFix do
|
|
56
56
|
expect(DummyMainModel.new).to respond_to :update
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
fixer
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
context "#update" do
|
60
|
+
|
61
|
+
it "calls fixer on update if update returns true and the entire" do
|
62
|
+
model_instance = DummyMainModel.new
|
63
|
+
model_instance.stub(:original_update) { true }
|
64
|
+
fixer = double(:fixer)
|
65
|
+
recreator = double(:recreator)
|
66
|
+
assigner = double(:assigner)
|
67
|
+
CarrierwaveReuploadFix::VersionsRecreator.stub(:new) { recreator }
|
68
|
+
CarrierwaveReuploadFix::ExtensionsAssigner.stub(:new) { assigner }
|
69
|
+
CarrierwaveReuploadFix::ReuploadFixer.should_receive(:new).with(model_instance,
|
70
|
+
recreator, assigner) { fixer }
|
71
|
+
fixer.should_receive(:fix)
|
72
|
+
model_instance.update({})
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns true if original_update returns true" do
|
76
|
+
model_instance = DummyMainModel.new
|
77
|
+
model_instance.stub(:original_update) { true }
|
78
|
+
CarrierwaveReuploadFix::VersionsRecreator.stub(:new)
|
79
|
+
CarrierwaveReuploadFix::ExtensionsAssigner.stub(:new)
|
80
|
+
CarrierwaveReuploadFix::ReuploadFixer.stub_chain(:new, :fix)
|
81
|
+
expect(model_instance.update({})).to be true
|
82
|
+
end
|
83
|
+
|
84
|
+
it "does not call fixer if original_update returns false" do
|
85
|
+
model_instance = DummyMainModel.new
|
86
|
+
model_instance.stub(:original_update) { false }
|
87
|
+
CarrierwaveReuploadFix::ReuploadFixer.should_not_receive(:new)
|
88
|
+
model_instance.update({})
|
89
|
+
end
|
90
|
+
|
91
|
+
it "returns false if original_update returns false" do
|
92
|
+
model_instance = DummyMainModel.new
|
93
|
+
model_instance.stub(:original_update) { false }
|
94
|
+
expect(model_instance.update({})).to be false
|
95
|
+
end
|
70
96
|
end
|
71
97
|
|
72
98
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave_reupload_fix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -100,6 +100,7 @@ extensions: []
|
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
102
|
- .gitignore
|
103
|
+
- CHANGELOG.md
|
103
104
|
- Gemfile
|
104
105
|
- LICENSE.txt
|
105
106
|
- README.md
|