has_draft 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTU4ZWMwNzY0M2I5NzhlMDUxNWE2ZGQ4NDkyZThhZGYwYzQ5MTQ0NQ==
5
- data.tar.gz: !binary |-
6
- YTVhZTQ1ZTc5MWQ1MDRmZmE0ZGU0ODlkMmM1NTY4OTZmYzBlMGViMg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NTUzNzRkMjkyMWIyYzBkOWFjYTFlZTMzZjkxNWI4ZjYzMTE0MTM5NDc2NGE0
10
- NWNiYTUwOWZkYjViOTFmOTQxYzQyYjY0YmMxYmM0MTBkMTRhN2QzYzJjNTQ2
11
- YjhlMWFiM2VjMzhiMzI3Mzk3MTA5YWYxZTJmODRhZjgzYzU4NDM=
12
- data.tar.gz: !binary |-
13
- Y2JkNDE3ZTZiZmU5M2EzMmVjNTE2MDc5MTVmZjFiOTc0OTU2YTk4Mjg4YjY0
14
- NzgxZmMwODIxMmMyMzNiNjk1OTI5NWU5NDQxZDMzYjFmNDYzYjdhMjdmMDNj
15
- NDA1ZTdmY2NhOTlmNTdlNWFjYjIwOGMwOGQ4OGRiOTFjOWY0ZDM=
2
+ SHA1:
3
+ metadata.gz: 43802ee528c537f22d4b0996caa82708366eca1a
4
+ data.tar.gz: 237e44c17d24fe2aa960a34123fb1f2b8e6637d9
5
+ SHA512:
6
+ metadata.gz: ab07707560bffdecf87a35b439f783a7a53ded60a733b22423e55eabd7a221ec947f787785e71c5d3731a7fdadbdcf1401b084b3e1a52061b043d026e95cdf1a
7
+ data.tar.gz: f6ebd0abcf1390d97c26109f397ee209a24bd1b3d78cd12a03264bd3e6a31c74d41b66b27d9ffbfd4ce3a4f8b8919336cb841a754400d76a37910d3bd71f4b95
data/Appraisals CHANGED
@@ -4,12 +4,20 @@ end
4
4
 
5
5
  appraise "3.1" do
6
6
  gem "rails", "~> 3.1.4"
7
+ gem "i18n", "~> 0.6.0"
8
+ gem "rack-cache", "~> 1.2.0"
7
9
  end
8
10
 
9
11
  appraise "3.2" do
10
12
  gem "rails", "~> 3.2.2"
13
+ gem "i18n", "~> 0.6.0"
14
+ gem "rack-cache", "~> 1.2.0"
11
15
  end
12
16
 
13
17
  appraise "4.0" do
14
18
  gem "rails", "~> 4.0.0"
15
19
  end
20
+
21
+ appraise "5.0" do
22
+ gem "rails", "~> 5.0.0"
23
+ end
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- has_draft (1.2.0)
4
+ has_draft (1.4.0)
5
5
  activerecord (>= 3.0.0)
6
6
  activesupport (>= 3.0.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (4.0.0)
12
- activesupport (= 4.0.0)
11
+ activemodel (4.0.3)
12
+ activesupport (= 4.0.3)
13
13
  builder (~> 3.1.0)
14
- activerecord (4.0.0)
15
- activemodel (= 4.0.0)
14
+ activerecord (4.0.3)
15
+ activemodel (= 4.0.3)
16
16
  activerecord-deprecated_finders (~> 1.0.2)
17
- activesupport (= 4.0.0)
17
+ activesupport (= 4.0.3)
18
18
  arel (~> 4.0.0)
19
- activerecord-deprecated_finders (1.0.3)
20
- activesupport (4.0.0)
19
+ activerecord-deprecated_finders (1.0.4)
20
+ activesupport (4.0.3)
21
21
  i18n (~> 0.6, >= 0.6.4)
22
22
  minitest (~> 4.2)
23
23
  multi_json (~> 1.3)
@@ -26,8 +26,7 @@ GEM
26
26
  appraisal (0.4.1)
27
27
  bundler
28
28
  rake
29
- arel (4.0.0)
30
- atomic (1.1.14)
29
+ arel (4.0.2)
31
30
  builder (3.1.4)
32
31
  diff-lcs (1.2.4)
33
32
  factory_girl (1.3.3)
@@ -35,7 +34,7 @@ GEM
35
34
  i18n (~> 0.4)
36
35
  i18n (0.6.5)
37
36
  minitest (4.7.5)
38
- multi_json (1.8.0)
37
+ multi_json (1.13.1)
39
38
  rake (10.1.0)
40
39
  rspec (2.14.1)
41
40
  rspec-core (~> 2.14.0)
@@ -45,10 +44,9 @@ GEM
45
44
  rspec-expectations (2.14.3)
46
45
  diff-lcs (>= 1.1.3, < 2.0)
47
46
  rspec-mocks (2.14.3)
48
- sqlite3 (1.3.8)
49
- thread_safe (0.1.3)
50
- atomic
51
- tzinfo (0.3.37)
47
+ sqlite3 (1.3.13)
48
+ thread_safe (0.3.6)
49
+ tzinfo (0.3.54)
52
50
 
53
51
  PLATFORMS
54
52
  ruby
@@ -58,6 +56,9 @@ DEPENDENCIES
58
56
  factory_girl (~> 1.3.1)
59
57
  faker (~> 0.9.1)
60
58
  has_draft!
61
- rake
59
+ rake (~> 10.1.0)
62
60
  rspec (~> 2.0)
63
61
  sqlite3 (~> 1.3.4)
62
+
63
+ BUNDLED WITH
64
+ 1.17.1
data/LICENSE CHANGED
@@ -1,20 +1,22 @@
1
- Copyright (c) 2010 Ben Hughes
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2013 Ben Hughes
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
13
22
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,6 @@
1
- {<img src="https://secure.travis-ci.org/rubiety/has_draft.png?branch=master" alt="Build Status" />}[http://travis-ci.org/rubiety/has_draft]
2
- {<img src="https://gemnasium.com/rubiety/has_draft.png" alt="Dependency Status" />}[https://gemnasium.com/rubiety/has_draft]
3
- {<img src="https://codeclimate.com/github/rubiety/has_draft.png" />}[https://codeclimate.com/github/rubiety/has_draft]
1
+ {<img src="https://secure.travis-ci.org/rubiety/has_draft.svg?branch=master" alt="Build Status" />}[http://travis-ci.org/rubiety/has_draft]
2
+ {<img src="https://gemnasium.com/rubiety/has_draft.svg" alt="Dependency Status" />}[https://gemnasium.com/rubiety/has_draft]
3
+ {<img src="https://codeclimate.com/github/rubiety/has_draft.svg" />}[https://codeclimate.com/github/rubiety/has_draft]
4
4
 
5
5
  == Has Draft
6
6
 
@@ -19,7 +19,7 @@ a Page::Draft class will exist as the model for the page_drafts table.
19
19
 
20
20
  == Installation
21
21
 
22
- This gem requires ActiveRecord 3.0.
22
+ This gem supports ActiveRecord 3, 4, and 5.
23
23
 
24
24
  In your Gemfile:
25
25
 
@@ -13,13 +13,17 @@ module HasDraft
13
13
  self.draft_class_name = options[:class_name] || 'Draft'
14
14
  self.draft_foreign_key = options[:foreign_key] || self.to_s.foreign_key
15
15
  self.draft_table_name = options[:table_name] || "#{table_name_prefix}#{base_class.name.demodulize.underscore}_drafts#{table_name_suffix}"
16
-
16
+
17
+ # Default parent association
18
+ options[:belongs_to] = self.to_s.demodulize.underscore.to_sym if options[:belongs_to].nil?
19
+
17
20
  # Create Relationship to Draft Copy
18
21
  class_eval do
19
22
  has_one :draft, :class_name => "#{self.to_s}::#{draft_class_name}",
20
23
  :foreign_key => draft_foreign_key,
21
- :dependent => :destroy
22
-
24
+ :dependent => :destroy,
25
+ :inverse_of => options[:belongs_to]
26
+
23
27
  scope :with_draft, lambda { includes(:draft).where("#{draft_table_name}.id IS NOT NULL") }
24
28
  scope :without_draft, lambda { includes(:draft).where("#{draft_table_name}.id IS NULL") }
25
29
  end
@@ -34,12 +38,9 @@ module HasDraft
34
38
  draft_class.original_class = self
35
39
  draft_class.table_name = draft_table_name
36
40
 
37
- # Default parent association
38
- options[:belongs_to] = self.to_s.demodulize.underscore.to_sym if options[:belongs_to].nil?
39
-
40
41
  # Draft Parent Association
41
- draft_class.belongs_to options[:belongs_to], :class_name => "::#{self.to_s}", :foreign_key => draft_foreign_key
42
-
42
+ draft_class.belongs_to options[:belongs_to], :class_name => "::#{self.to_s}", :foreign_key => draft_foreign_key, :inverse_of => :draft
43
+
43
44
  # Block extension
44
45
  draft_class.class_eval(&block) if block_given?
45
46
 
@@ -1,3 +1,3 @@
1
1
  module HasDraft
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
Binary file
@@ -49,6 +49,12 @@ describe HasDraft do
49
49
  @article.send(column).should == @article.draft.send(column)
50
50
  end
51
51
  end
52
+
53
+ it "should set the associations as inverses of each other" do
54
+ @article.draft.article.should be @article
55
+ article_draft = Article::Draft.find(@article.draft.id)
56
+ article_draft.article.draft.should be article_draft
57
+ end
52
58
  end
53
59
 
54
60
  context "when destroying an existing draft" do
metadata CHANGED
@@ -1,127 +1,127 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_draft
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Hughes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-05 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
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: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.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: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: factory_girl
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.3.1
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
68
  version: 1.3.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faker
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.9.1
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.9.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sqlite3
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.3.4
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.3.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: appraisal
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.4.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.4.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 10.1.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 10.1.0
125
125
  description: Allows for your ActiveRecord models to have drafts which are stored in
126
126
  a separate duplicate table.
127
127
  email: ben@railsgarden.com
@@ -129,24 +129,25 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - Appraisals
133
+ - Gemfile
134
+ - Gemfile.lock
135
+ - LICENSE
136
+ - README.rdoc
137
+ - Rakefile
138
+ - init.rb
139
+ - lib/has_draft.rb
132
140
  - lib/has_draft/railtie.rb
133
141
  - lib/has_draft/version.rb
134
- - lib/has_draft.rb
135
142
  - spec/db/database.yml
136
143
  - spec/db/schema.rb
137
144
  - spec/db/test.sqlite3
138
145
  - spec/factories/article.rb
139
146
  - spec/has_draft_spec.rb
140
147
  - spec/spec_helper.rb
141
- - Appraisals
142
- - Gemfile
143
- - Gemfile.lock
144
- - LICENSE
145
- - Rakefile
146
- - README.rdoc
147
- - init.rb
148
148
  homepage: http://github.com/rubiety/has_draft
149
- licenses: []
149
+ licenses:
150
+ - MIT
150
151
  metadata: {}
151
152
  post_install_message:
152
153
  rdoc_options: []
@@ -154,17 +155,17 @@ require_paths:
154
155
  - lib
155
156
  required_ruby_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
- - - ! '>='
158
+ - - ">="
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  required_rubygems_version: !ruby/object:Gem::Requirement
161
162
  requirements:
162
- - - ! '>='
163
+ - - ">="
163
164
  - !ruby/object:Gem::Version
164
165
  version: 1.3.4
165
166
  requirements: []
166
167
  rubyforge_project: has_draft
167
- rubygems_version: 2.0.6
168
+ rubygems_version: 2.5.1
168
169
  signing_key:
169
170
  specification_version: 4
170
171
  summary: Attached draft model to your ActiveRecord models.