saviour 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +19 -0
- data/Appraisals +19 -0
- data/gemfiles/4.0.gemfile +9 -0
- data/gemfiles/4.1.gemfile +9 -0
- data/gemfiles/4.2.gemfile +9 -0
- data/gemfiles/5.0.gemfile +9 -0
- data/lib/saviour.rb +4 -5
- data/lib/saviour/base_uploader.rb +6 -4
- data/lib/saviour/{base_integrator.rb → integrator.rb} +23 -5
- data/lib/saviour/local_storage.rb +1 -1
- data/lib/saviour/model.rb +24 -0
- data/lib/saviour/persistence_layer.rb +19 -0
- data/lib/saviour/s3_storage.rb +2 -5
- data/lib/saviour/url_source.rb +1 -0
- data/lib/saviour/validator.rb +50 -0
- data/lib/saviour/version.rb +1 -1
- data/saviour.gemspec +6 -1
- data/spec/feature/access_to_model_and_mounted_as_spec.rb +2 -2
- data/spec/feature/crud_workflows_spec.rb +143 -0
- data/spec/feature/persisted_path_spec.rb +34 -0
- data/spec/feature/reload_model_spec.rb +24 -0
- data/spec/feature/validations_spec.rb +178 -0
- data/spec/feature/versions_spec.rb +49 -72
- data/spec/models/model_spec.rb +128 -0
- data/spec/models/s3_storage_spec.rb +0 -6
- data/spec/spec_helper.rb +25 -0
- data/spec/support/models.rb +7 -3
- data/spec/support/schema.rb +9 -0
- metadata +75 -9
- data/DECOMPOSE.md +0 -66
- data/lib/saviour/basic_model.rb +0 -7
- data/lib/saviour/utils/class_attribute.rb +0 -26
- data/spec/models/basic_model_spec.rb +0 -51
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Saviour do
|
4
|
-
describe ".attached_files" do
|
5
|
-
it "includes a mapping of the currently attached files and their versions" do
|
6
|
-
uploader = Class.new(Saviour::BaseUploader) do
|
7
|
-
store_dir { "/store/dir" }
|
8
|
-
|
9
|
-
version(:thumb)
|
10
|
-
version(:thumb_2)
|
11
|
-
end
|
12
|
-
|
13
|
-
klass = Class.new do
|
14
|
-
include Saviour::BasicModel
|
15
|
-
attach_file :file, uploader
|
16
|
-
end
|
17
|
-
|
18
|
-
expect(klass.attached_files).to eq({file: [:thumb, :thumb_2]})
|
19
|
-
|
20
|
-
klass2 = Class.new do
|
21
|
-
include Saviour::BasicModel
|
22
|
-
attach_file :file, Saviour::BaseUploader
|
23
|
-
end
|
24
|
-
|
25
|
-
expect(klass2.attached_files).to eq({file: []})
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "doens't mess with default File constant" do
|
30
|
-
# Constant lookup in ruby works by lexical scope, so we can't create classes dynamically like above.
|
31
|
-
expect(TestForSaviourFileResolution.new.foo).to be_falsey
|
32
|
-
end
|
33
|
-
|
34
|
-
it "shares model definitions with subclasses" do
|
35
|
-
uploader = Class.new(Saviour::BaseUploader) do
|
36
|
-
store_dir { "/store/dir" }
|
37
|
-
version(:thumb)
|
38
|
-
end
|
39
|
-
|
40
|
-
klass = Class.new do
|
41
|
-
include Saviour::BasicModel
|
42
|
-
attach_file :file, uploader
|
43
|
-
end
|
44
|
-
expect(klass.attached_files).to eq({file: [:thumb]})
|
45
|
-
|
46
|
-
klass2 = Class.new(klass)
|
47
|
-
expect(klass2.attached_files).to eq({file: [:thumb]})
|
48
|
-
|
49
|
-
expect(klass2.new.file).to respond_to :exists?
|
50
|
-
end
|
51
|
-
end
|