draftsman 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb576cc8ff96c4d3e43ffd8c08470200e5968c0f
4
- data.tar.gz: 3759e4dd3b0e09007c0ce94b6f8cc11f9f49e503
3
+ metadata.gz: 74e4cf230e28a0fa2b097c33c0a3bb40360b4c3e
4
+ data.tar.gz: 549d0072468f067a86480273989d6a0b86118c99
5
5
  SHA512:
6
- metadata.gz: 68ae774e981b6f401b4230d0ee313158c679ebf2ebb6accde016c92e280d24bec28e24da0ac30901ec0f3ed74df53b08b91905175425dd25efdbe8d4e696b7d7
7
- data.tar.gz: 8366dfbccdb59440839a2a184dffa4543cc126db74bce1f01efe96d20f960025ba4a38063d6e581104cc2d8df40a8dab4a76ae23491b63f45ad7b6eec7dc190a
6
+ metadata.gz: 5dfed02ea98a99d534b3833327f4927b47e93ee4237899fe7c75e02ccd660195c4d562b5bf1dbdafbddb0343e19280a945eb773ee80a41dfd7625a7e2d237cc2
7
+ data.tar.gz: c4df9a57b0da2602328d995557a867936560965c6f4897d991107abc019789eea7d74ba4a35274e9777f469d353163b167aa00e5f23630b5cd89b2507377d092
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
- ## v0.1.0
3
+ ## v0.1.1 - March 7, 2014
4
4
 
5
- * Initial release.
5
+ - Fixed [#3](https://github.com/minimalorange/draftsman/issues/3) - draft_publication_dependencies not honoring drafts
6
+ when draft is an update.
7
+ - Fixed [#1](https://github.com/minimalorange/draftsman/issues/1) - License missing from gemspec - Added MIT license.
8
+
9
+ ## v0.1.0 - November 19, 2013
10
+
11
+ - Initial release.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- draftsman (0.1.0)
4
+ draftsman (0.1.1)
5
5
  activerecord (>= 3.0, < 5.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Draftsman v0.1.0 (alpha)
1
+ # Draftsman v0.1.1 (alpha)
2
2
 
3
3
  Draftsman is a Ruby gem that lets you create draft versions of your database records. If you're developing a system in
4
4
  need of simple drafts or a publishing approval queue, then Draftsman just might be what you need.
@@ -11,9 +11,9 @@ need of simple drafts or a publishing approval queue, then Draftsman just might
11
11
  * The RSpec tests are lacking in some areas, so I will be adding to those over time as well. (Unfortunately, this gem
12
12
  was not developed with TDD best practices because it was lifted from PaperTrail and modified from there.)
13
13
 
14
- This gem is inspired by the [Kentouzu][1] gem, which is based heavily on [PaperTrail][2]. In fact, much of the code for
15
- this gem was lifted line for line from PaperTrail (because it works beautifully). You should definitely check out
16
- PaperTrail and its source: it's a nice clean example of a gem that hooks into Rails and Sinatra.
14
+ This gem is inspired by the [Kentouzu][1] gem, which is based heavily on [PaperTrail][2]. In fact, much of the structure
15
+ for this gem emulates PaperTrail (because it works beautifully). You should definitely check out PaperTrail and its
16
+ source: it's a nice clean example of a gem that hooks into Rails and Sinatra.
17
17
 
18
18
  ## Features
19
19
 
@@ -50,7 +50,7 @@ Works well with Rails, Sinatra, or any other application that depends on ActiveR
50
50
  Add Draftsman to your `Gemfile`.
51
51
 
52
52
  ```ruby
53
- gem 'draftsman', '0.1.0'
53
+ gem 'draftsman', '0.1.1'
54
54
  ```
55
55
 
56
56
  Or if you want to grab the latest from `master`:
@@ -77,7 +77,7 @@ Run the migration(s).
77
77
  Add `draft_id`, `published_at`, and `trashed_at` attributes to the models you want to have drafts on. `trashed_at` is
78
78
  optional if you don't want to store drafts for destroys.
79
79
 
80
- $ rails g migration add_draft_id_published_at_trashed_at_to_widgets draft_id:integer published_at:timestamp trashed_at:timestamp
80
+ $ rails g migration add_drafts_to_widgets draft_id:integer published_at:timestamp trashed_at:timestamp
81
81
  $ rake db:migrate
82
82
 
83
83
  Add `has_drafts` to the models you want to have drafts on.
@@ -496,6 +496,10 @@ Rails guide:
496
496
  This gem is a work in progress. I am adding specs as I need features in my application. Please add missing ones as you
497
497
  work on features or find bugs!
498
498
 
499
+ ## License
500
+
501
+ Draftsman is released under the [MIT License][9].
502
+
499
503
 
500
504
  [1]: https://github.com/seaneshbaugh/kentouzu
501
505
  [2]: https://github.com/airblade/paper_trail
@@ -504,3 +508,4 @@ work on features or find bugs!
504
508
  [6]: https://github.com/janko-m/sinatra-activerecord
505
509
  [7]: https://raw.github.com/minimalorange/draftsman/master/lib/generators/draftsman/templates/create_drafts.rb
506
510
  [8]: http://www.sinatrarb.com/intro.html#Modular%20vs.%20Classic%20Style
511
+ [9]: http://www.opensource.org/licenses/MIT
data/draftsman.gemspec CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.homepage = 'https://github.com/minimalorange/draftsman'
10
10
  s.authors = ['Chris Peters']
11
11
  s.email = 'chris@minimalorange.com'
12
+ s.license = 'MIT'
12
13
 
13
14
  s.files = `git ls-files`.split("\n")
14
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -52,25 +52,27 @@ class Draftsman::Draft < ActiveRecord::Base
52
52
  def draft_publication_dependencies
53
53
  dependencies = []
54
54
 
55
+ my_item = self.item.draft? ? self.item.draft.reify : self.item
56
+
55
57
  case self.event
56
58
  when 'create', 'update'
57
- associations = self.item.class.reflect_on_all_associations(:belongs_to)
59
+ associations = my_item.class.reflect_on_all_associations(:belongs_to)
58
60
 
59
61
  associations.each do |association|
60
62
  association_class =
61
63
  if association.polymorphic?
62
- self.item.send(association.foreign_key.sub('_id', '_type')).constantize
64
+ my_item.send(association.foreign_key.sub('_id', '_type')).constantize
63
65
  else
64
66
  association.klass
65
67
  end
66
68
 
67
69
  if association_class.draftable? && association.name != association_class.draft_association_name.to_sym
68
- dependency = self.item.send(association.name)
70
+ dependency = my_item.send(association.name)
69
71
  dependencies << dependency.draft if dependency.present? && dependency.draft? && dependency.draft.create?
70
72
  end
71
73
  end
72
74
  when 'destroy'
73
- associations = self.item.class.reflect_on_all_associations(:has_one) + self.item.class.reflect_on_all_associations(:has_many)
75
+ associations = my_item.class.reflect_on_all_associations(:has_one) + my_item.class.reflect_on_all_associations(:has_many)
74
76
 
75
77
  associations.each do |association|
76
78
  if association.klass.draftable?
@@ -78,9 +80,9 @@ class Draftsman::Draft < ActiveRecord::Base
78
80
  associated_dependencies =
79
81
  case association.macro
80
82
  when :has_one
81
- self.item.send(association.name).present? ? [self.item.send(association.name)] : []
83
+ my_item.send(association.name).present? ? [my_item.send(association.name)] : []
82
84
  when :has_many
83
- self.item.send(association.name)
85
+ my_item.send(association.name)
84
86
  end
85
87
 
86
88
  associated_dependencies.each do |dependency|
@@ -1,3 +1,3 @@
1
1
  module Draftsman
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -150,7 +150,7 @@ describe Child do
150
150
  end
151
151
 
152
152
  subject { child.draft }
153
- its(:draft_publication_dependencies) { should be_present }
153
+ its(:draft_publication_dependencies) { should_not be_empty }
154
154
  its(:draft_publication_dependencies) { should include parent.draft }
155
155
  end
156
156
 
@@ -163,10 +163,26 @@ describe Child do
163
163
  end
164
164
 
165
165
  subject { child.draft }
166
- its(:draft_publication_dependencies) { should be_present }
166
+ its(:draft_publication_dependencies) { should_not be_empty }
167
167
  its(:draft_publication_dependencies) { should include parent.draft }
168
168
  end
169
169
 
170
+ context 'parent `create` draft with child `update` draft pointing to new parent' do
171
+ let(:new_parent) { Parent.new(:name => 'Patty') }
172
+ before do
173
+ parent.draft_creation
174
+ child.save!
175
+ new_parent.draft_creation
176
+ child.parent = new_parent
177
+ child.draft_update
178
+ end
179
+
180
+ subject { child.draft }
181
+ its(:draft_publication_dependencies) { should_not be_empty }
182
+ its(:draft_publication_dependencies) { should_not include parent.draft}
183
+ its(:draft_publication_dependencies) { should include new_parent.draft }
184
+ end
185
+
170
186
  context 'parent `destroy` draft with child `destroy` draft' do
171
187
  before do
172
188
  child.save!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draftsman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Peters
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-19 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -223,7 +223,8 @@ files:
223
223
  - spec/models/whitelister_spec.rb
224
224
  - spec/spec_helper.rb
225
225
  homepage: https://github.com/minimalorange/draftsman
226
- licenses: []
226
+ licenses:
227
+ - MIT
227
228
  metadata: {}
228
229
  post_install_message:
229
230
  rdoc_options: []