saviour 0.4.11 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/saviour/file.rb +4 -2
- data/lib/saviour/model.rb +1 -1
- data/lib/saviour/version.rb +1 -1
- data/spec/feature/introspection_spec.rb +40 -0
- data/spec/feature/reload_model_spec.rb +1 -1
- data/spec/models/file_spec.rb +14 -0
- data/spec/models/model_spec.rb +0 -15
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d28e5f8f325721c27a7f763b9733070cf20e3dce6a9acfa7253249a7995ae51c
|
4
|
+
data.tar.gz: d5d81ed8993b2c848d4746e85bd9686c291dff58d61bd3f7eebbdc7f6099246f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac2b201f3aad2cdd39cb8092d0becdc9d1833f508971f3a33d1d460a9abf83199d6ed9caab807ec72217191adee0585c5cbb53162d3c87e92d46dd34491fd98
|
7
|
+
data.tar.gz: 6ee49e6b551deadf44596066c96a89bcb0dab781e0d7693b99c9af9687b6584bf8b4da58319ce0917cf12c85010aa83b04ae74262cba96b065d272c3e1148ac2
|
data/lib/saviour/file.rb
CHANGED
@@ -19,7 +19,8 @@ module Saviour
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def read
|
22
|
-
persisted?
|
22
|
+
return nil unless persisted?
|
23
|
+
Config.storage.read(@persisted_path)
|
23
24
|
end
|
24
25
|
|
25
26
|
def delete
|
@@ -30,7 +31,8 @@ module Saviour
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def public_url
|
33
|
-
persisted?
|
34
|
+
return nil unless persisted?
|
35
|
+
Config.storage.public_url(@persisted_path)
|
34
36
|
end
|
35
37
|
|
36
38
|
def ==(another_file)
|
data/lib/saviour/model.rb
CHANGED
data/lib/saviour/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Introspection of attached files" do
|
4
|
+
before { allow(Saviour::Config).to receive(:storage).and_return(Saviour::LocalStorage.new(local_prefix: @tmpdir, public_url_prefix: "http://domain.com")) }
|
5
|
+
|
6
|
+
let(:uploader) {
|
7
|
+
Class.new(Saviour::BaseUploader) do
|
8
|
+
store_dir { "/store/dir" }
|
9
|
+
end
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:uploader_for_version) {
|
13
|
+
Class.new(Saviour::BaseUploader) do
|
14
|
+
store_dir { "/store/dir" }
|
15
|
+
|
16
|
+
process do |contents, filename|
|
17
|
+
[contents, "new_#{filename}"]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:klass) {
|
23
|
+
a = Class.new(Test) { include Saviour::Model }
|
24
|
+
a.attach_file :file, uploader
|
25
|
+
a.attach_file :file_thumb, uploader_for_version, follow: :file
|
26
|
+
a
|
27
|
+
}
|
28
|
+
|
29
|
+
describe "Model.attached_files" do
|
30
|
+
it "includes a mapping of the currently attached files" do
|
31
|
+
expect(klass.attached_files).to eq([:file, :file_thumb])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Model.attached_followers_per_leader" do
|
36
|
+
it "is a hash of attachments and followers" do
|
37
|
+
expect(klass.attached_followers_per_leader).to eq({ file: [:file_thumb] })
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/models/file_spec.rb
CHANGED
@@ -204,4 +204,18 @@ describe Saviour::File do
|
|
204
204
|
expect(a).to_not eq b
|
205
205
|
end
|
206
206
|
end
|
207
|
+
|
208
|
+
describe "#read" do
|
209
|
+
it "returns nil when there's no file persisted" do
|
210
|
+
a = Saviour::File.new(uploader_klass, dummy_class.new, :file)
|
211
|
+
expect(a.read).to be_nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
describe "#public_url" do
|
216
|
+
it "returns nil when there's no file persisted" do
|
217
|
+
a = Saviour::File.new(uploader_klass, dummy_class.new, :file)
|
218
|
+
expect(a.public_url).to be_nil
|
219
|
+
end
|
220
|
+
end
|
207
221
|
end
|
data/spec/models/model_spec.rb
CHANGED
@@ -9,21 +9,6 @@ describe Saviour do
|
|
9
9
|
}.to raise_error(Saviour::NoActiveRecordDetected)
|
10
10
|
end
|
11
11
|
|
12
|
-
describe ".attached_files" do
|
13
|
-
it "includes a mapping of the currently attached files" do
|
14
|
-
uploader = Class.new(Saviour::BaseUploader) do
|
15
|
-
store_dir { "/store/dir" }
|
16
|
-
end
|
17
|
-
|
18
|
-
klass = Class.new(Test) do
|
19
|
-
include Saviour::Model
|
20
|
-
attach_file :file, uploader
|
21
|
-
end
|
22
|
-
|
23
|
-
expect(klass.attached_files).to eq([:file])
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
12
|
it "doens't mess with default File constant" do
|
28
13
|
# Constant lookup in ruby works by lexical scope, so we can't create classes dynamically like above.
|
29
14
|
expect(TestForSaviourFileResolution.new.foo).to be_falsey
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saviour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Campos
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- spec/feature/dirty_spec.rb
|
191
191
|
- spec/feature/follow_file_spec.rb
|
192
192
|
- spec/feature/halt_processor_spec.rb
|
193
|
+
- spec/feature/introspection_spec.rb
|
193
194
|
- spec/feature/memory_usage_spec.rb
|
194
195
|
- spec/feature/original_assigned_file_is_not_modified_spec.rb
|
195
196
|
- spec/feature/persisted_path_spec.rb
|