paperclip_database 2.3.0 → 2.3.1
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/paperclip/storage/database.rb +5 -1
- data/lib/paperclip_database/version.rb +1 -1
- data/spec/default_options_spec.rb +4 -4
- data/spec/major_version_API_spec.rb +42 -38
- data/spec/namespaced_models_spec.rb +2 -2
- data/spec/single_table_inheritance_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e61f9497eb7f63600507677ed812ec06d73b91f3
|
4
|
+
data.tar.gz: f7d6a7b6078a95793d1c2f5ed28f72aed0b95930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b2763dd5d3b108329f2ab1b22c9ee364881ce27e7dfb2b0e0c30e3530569a2fbb2af2e31ce5511200a16701864a291193e80628a1c065ce2086d39fc7342e63
|
7
|
+
data.tar.gz: 79cbf57c646fc0e96e853625f9e3d7777b1f5a870000117c0b2424cb3e2a51b795e67be37eadbb4d266bd186de81c2897edcf286b3f787c4689503a14d08eb98
|
@@ -82,7 +82,7 @@ module Paperclip
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def setup_paperclip_files_association
|
85
|
-
@paperclip_files_association_name =
|
85
|
+
@paperclip_files_association_name = @paperclip_file_model.name.demodulize.tableize
|
86
86
|
@database_table = @paperclip_file_model.table_name
|
87
87
|
#FIXME: This fails when using set_table_name "<myname>" in your model
|
88
88
|
#FIXME: This should be fixed in ActiveRecord...
|
@@ -170,6 +170,10 @@ module Paperclip
|
|
170
170
|
end
|
171
171
|
alias_method :to_io, :to_file
|
172
172
|
|
173
|
+
def files
|
174
|
+
instance.send("#{@paperclip_files_association_name}")
|
175
|
+
end
|
176
|
+
|
173
177
|
def file_for(style)
|
174
178
|
db_result = instance.send("#{@paperclip_files_association_name}").send(:file_for, style.to_s)
|
175
179
|
raise RuntimeError, "More than one result for #{style}" if db_result.size > 1
|
@@ -24,7 +24,7 @@ describe "PaperclipDatabase" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "has association name" do
|
27
|
-
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq '
|
27
|
+
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq 'user_avatar_paperclip_files'
|
28
28
|
end
|
29
29
|
|
30
30
|
it "has model constant" do
|
@@ -32,7 +32,7 @@ describe "PaperclipDatabase" do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "has association" do
|
35
|
-
expect(@model.methods.include?(:
|
35
|
+
expect(@model.methods.include?(:user_avatar_paperclip_files)).to be_truthy
|
36
36
|
end
|
37
37
|
end
|
38
38
|
describe "Namespaced model" do
|
@@ -59,7 +59,7 @@ describe "PaperclipDatabase" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "has association name" do
|
62
|
-
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq '
|
62
|
+
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq 'user_avatar_paperclip_files'
|
63
63
|
end
|
64
64
|
|
65
65
|
it "has model constant" do
|
@@ -67,7 +67,7 @@ describe "PaperclipDatabase" do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "has association" do
|
70
|
-
expect(@model.methods.include?(:
|
70
|
+
expect(@model.methods.include?(:user_avatar_paperclip_files)).to be_truthy
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -1,21 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
##
|
4
|
-
## named subject '
|
4
|
+
## named subject 'attachment' is the SUT
|
5
5
|
# args can be
|
6
6
|
# [:table_name] The table name
|
7
7
|
#
|
8
8
|
shared_examples_for "major version API compatible" do |args|
|
9
9
|
table_name = args[:table_name]
|
10
10
|
describe "Major version compatible with table name '#{table_name}'" do
|
11
|
+
subject{attachment}
|
11
12
|
it "has table name '#{table_name}'" do
|
12
|
-
expect(
|
13
|
+
expect(subject.instance_variable_get(:@database_table)).to eq table_name
|
13
14
|
end
|
15
|
+
##Basic (common)
|
16
|
+
it { is_expected.to respond_to(:exists?).with(1).argument }
|
17
|
+
it { is_expected.to respond_to(:flush_writes).with(0).argument }
|
18
|
+
it { is_expected.to respond_to(:flush_deletes).with(0).argument }
|
19
|
+
it { is_expected.to respond_to(:copy_to_local_file).with(2).arguments }
|
20
|
+
|
21
|
+
##Database specific
|
22
|
+
it { is_expected.to respond_to(:files).with(0).arguments }
|
23
|
+
it { is_expected.to respond_to(:database_path).with(1).argument }
|
24
|
+
it { is_expected.to respond_to(:to_file).with(1).argument }
|
25
|
+
it { is_expected.to respond_to(:to_io).with(1).argument }
|
26
|
+
it { is_expected.to respond_to(:file_for).with(1).argument }
|
27
|
+
it { is_expected.to respond_to(:file_contents).with(1).argument }
|
14
28
|
end
|
15
29
|
end
|
16
30
|
|
17
31
|
## named subject 'namespace' is the SUT
|
18
|
-
shared_examples_for "model
|
32
|
+
shared_examples_for "model" do |args|
|
19
33
|
describe "with default options" do
|
20
34
|
let!(:model_name){"#{namespace}User"}
|
21
35
|
let!(:attachment_name){'avatar'}
|
@@ -43,43 +57,33 @@ shared_examples_for "model in namespace" do |args|
|
|
43
57
|
end
|
44
58
|
|
45
59
|
describe "PaperclipDatabase" do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
extra_paperclip_options = defined?(attachment_table_name)? {:database_table => attachment_table_name.to_sym} : {}
|
60
|
+
before(:example) do
|
61
|
+
@attachment_table_name = defined?(attachment_table_name) ? attachment_table_name : attachment_name.tableize
|
62
|
+
extra_paperclip_options = defined?(attachment_table_name)? {:database_table => attachment_table_name.to_sym} : {}
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
build_model model_name, (defined?(model_table_name)? model_table_name: nil), attachment_name.to_sym, extra_paperclip_options
|
65
|
+
@model_table_name = model_name.constantize.table_name
|
66
|
+
create_model_tables @model_table_name, @attachment_table_name, attachment_name
|
67
|
+
@model = model_name.constantize.new
|
68
|
+
file = File.open(fixture_file('5k.png'))
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
70
|
+
@model.send(:"#{attachment_name}=",file)
|
71
|
+
@model.save
|
72
|
+
end
|
73
|
+
subject(:attachment){@model.avatar}
|
74
|
+
after(:example) do
|
75
|
+
reset_activerecord
|
76
|
+
reset_database @model_table_name, @attachment_table_name
|
77
|
+
end
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
subject(:namespace){'Object::'}
|
76
|
-
it_behaves_like "model in namespace"
|
77
|
-
end
|
78
|
-
describe "namespace 'Namespace::'" do
|
79
|
-
before(:context) { Object.const_set('Namespace', Module.new()) }
|
80
|
-
after(:context) { Object.send(:remove_const, 'Namespace') }
|
81
|
-
subject(:namespace){'Namespace::'}
|
82
|
-
it_behaves_like "model in namespace"
|
83
|
-
end
|
79
|
+
describe "model with no namespace" do
|
80
|
+
subject(:namespace){''}
|
81
|
+
it_behaves_like "model"
|
82
|
+
end
|
83
|
+
describe "model in namespace 'Namespace::'" do
|
84
|
+
before(:context) { Object.const_set('Namespace', Module.new()) }
|
85
|
+
after(:context) { Object.send(:remove_const, 'Namespace') }
|
86
|
+
subject(:namespace){'Namespace::'}
|
87
|
+
it_behaves_like "model"
|
84
88
|
end
|
85
89
|
end
|
@@ -21,7 +21,7 @@ describe "PaperclipDatabase" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "has correct association name" do
|
24
|
-
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq '
|
24
|
+
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq 'namespace_model_avatar_paperclip_files'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "has correct model constant" do
|
@@ -33,7 +33,7 @@ describe "PaperclipDatabase" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "has association" do
|
36
|
-
expect(@model.methods.include?(:
|
36
|
+
expect(@model.methods.include?(:namespace_model_avatar_paperclip_files)).to be_truthy
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
@@ -21,7 +21,7 @@ describe "PaperclipDatabase" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "has correct association name" do
|
24
|
-
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq '
|
24
|
+
expect(@model.avatar.instance_variable_get(:@paperclip_files_association_name)).to eq 'user_avatar_paperclip_files'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "has correct model constant" do
|
@@ -33,7 +33,7 @@ describe "PaperclipDatabase" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "has association" do
|
36
|
-
expect(@model.methods.include?(:
|
36
|
+
expect(@model.methods.include?(:user_avatar_paperclip_files)).to be_truthy
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip_database
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarl Friis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paperclip
|