conscript 0.2.1 → 0.2.3

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.
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
+ ## v0.2.3
2
+
3
+ * Fixed a failing scenario where associated objects modified the parent object before the parent was destroyed
4
+ * Fixed a failing scenario where inverse relationship was not detected under certain conditions
5
+
6
+ ## v0.2.2
7
+
8
+ * Fixed regression bug where attributes were sometimes not being copied over to the draft parent.
9
+
1
10
  ## v0.2.1
2
11
 
3
12
  * Fixed bug where associated `has_many` records with CarrierWave uploads were not duplicated correctly - uploaded files are now copied
4
13
  * Fixed bug where destroying a draft would remove an uploaded file from its draft parent if they shared the same file.
5
- * Fixed bug where drafts were destroyed before publish_Draft was successful
14
+ * Fixed bug where drafts were destroyed before `publish_draft` was successful
6
15
  * Added an ActiveRecord error where `save` fails if drafts exist for an instance
7
16
 
8
17
  ## v0.2.0
@@ -21,7 +21,7 @@ module Conscript
21
21
  self.conscript_options[:ignore_attributes].map!(&:to_s)
22
22
  self.conscript_options.update options.slice(:allow_update_with_drafts, :destroy_drafts_on_publish)
23
23
 
24
- belongs_to :draft_parent, class_name: self
24
+ belongs_to :draft_parent, class_name: self, inverse_of: :drafts
25
25
  has_many :drafts, conditions: {is_draft: true}, class_name: self, foreign_key: :draft_parent_id, dependent: :destroy, inverse_of: :draft_parent
26
26
 
27
27
  define_callbacks :publish_draft, :save_as_draft
@@ -64,25 +64,29 @@ module Conscript
64
64
  run_callbacks :publish_draft do
65
65
  raise Conscript::Exception::NotADraft unless is_draft?
66
66
  return self.update_attribute(:is_draft, false) if !draft_parent_id
67
+ parent = self.draft_parent
67
68
  ::ActiveRecord::Base.transaction do
68
- draft_parent.assign_attributes attributes_to_publish, without_protection: true
69
+ parent.assign_attributes attributes_to_publish, without_protection: true
69
70
 
70
71
  self.class.conscript_options[:associations].each do |association|
71
72
  case reflections[association].macro
72
73
  when :has_many
73
- draft_parent.send(association.to_s + "=", self.send(association).collect {|child| child.dup do |original, dup|
74
- # Workaround for CarrierWave uploaders on associated records. Copy the uploaded files.
75
- if dup.class.respond_to? :uploaders
76
- dup.class.uploaders.keys.each {|uploader| dup.send(uploader.to_s + "=", original.send(uploader)) }
74
+ parent.send(association.to_s + "=", self.send(association).collect do |child|
75
+ child.dup do |original, dup|
76
+ # Workaround for CarrierWave uploaders on associated records. Copy the uploaded files.
77
+ if dup.class.respond_to? :uploaders
78
+ dup.class.uploaders.keys.each {|uploader| dup.send(uploader.to_s + "=", original.send(uploader)) }
79
+ end
77
80
  end
78
- end })
81
+ end)
79
82
  end
80
83
  end
81
84
 
85
+ self.reload
82
86
  self.destroy
83
- draft_parent.save!
87
+ parent.save!
84
88
  end
85
- draft_parent
89
+ parent
86
90
  end
87
91
  end
88
92
 
@@ -1,3 +1,3 @@
1
1
  module Conscript
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-12 00:00:00.000000000Z
12
+ date: 2013-07-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70350313257540 !ruby/object:Gem::Requirement
16
+ requirement: &70300252198620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.5
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70350313257540
24
+ version_requirements: *70300252198620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70350313257120 !ruby/object:Gem::Requirement
27
+ requirement: &70300252198040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70350313257120
35
+ version_requirements: *70300252198040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70350313256600 !ruby/object:Gem::Requirement
38
+ requirement: &70300252195300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70350313256600
46
+ version_requirements: *70300252195300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &70350313256180 !ruby/object:Gem::Requirement
49
+ requirement: &70300252194860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70350313256180
57
+ version_requirements: *70300252194860
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activerecord
60
- requirement: &70350313255560 !ruby/object:Gem::Requirement
60
+ requirement: &70300252194360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 3.2.13
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70350313255560
68
+ version_requirements: *70300252194360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: deep_cloneable
71
- requirement: &70350313254920 !ruby/object:Gem::Requirement
71
+ requirement: &70300252193860 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 1.5.2
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70350313254920
79
+ version_requirements: *70300252193860
80
80
  description: Provides ActiveRecord models with draft instances, including associations
81
81
  email:
82
82
  - steve@stevelorek.com