controlled_versioning 0.6.3 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/MIT-LICENSE +1 -1
- data/Rakefile +0 -6
- data/app/assets/javascripts/controlled_versioning/application.js +13 -0
- data/app/assets/stylesheets/controlled_versioning/application.css +13 -0
- data/app/controllers/controlled_versioning/application_controller.rb +4 -0
- data/app/helpers/controlled_versioning/application_helper.rb +4 -0
- data/app/models/controlled_versioning/version.rb +23 -0
- data/app/models/controlled_versioning/version_attribute.rb +8 -0
- data/app/models/controlled_versioning/version_child.rb +9 -0
- data/app/views/layouts/controlled_versioning/application.html.erb +14 -0
- data/lib/controlled_versioning/engine.rb +16 -0
- data/lib/controlled_versioning/version_number.rb +1 -1
- data/lib/controlled_versioning.rb +2 -0
- data/spec/controlled_versioning_spec.rb +316 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/child_resource.rb +10 -0
- data/spec/dummy/app/models/grand_child_resource.rb +7 -0
- data/spec/dummy/app/models/nonversionable_resource.rb +2 -0
- data/spec/dummy/app/models/parent_resource.rb +9 -0
- data/spec/dummy/app/models/partially_exclusive_versionable_resource.rb +3 -0
- data/spec/dummy/app/models/partially_inclusive_versionable_resource.rb +3 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/models/versionable_resource.rb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +60 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20140117222800_create_users.rb +11 -0
- data/spec/dummy/db/migrate/20140117222808_create_versionable_resources.rb +17 -0
- data/spec/dummy/db/migrate/20140117222814_create_partially_inclusive_versionable_resources.rb +17 -0
- data/spec/dummy/db/migrate/20140117222815_create_partially_exclusive_versionable_resources.rb +17 -0
- data/spec/dummy/db/migrate/20140117222828_create_nonversionable_resources.rb +17 -0
- data/spec/dummy/db/migrate/20140117222840_create_parent_resources.rb +17 -0
- data/spec/dummy/db/migrate/20140117222841_create_child_resources.rb +19 -0
- data/spec/dummy/db/migrate/20140117222842_create_grand_child_resources.rb +19 -0
- data/spec/dummy/db/migrate/20140206173607_create_controlled_versioning_versions.controlled_versioning.rb +30 -0
- data/spec/dummy/db/migrate/20140206173608_create_controlled_versioning_version_attributes.controlled_versioning.rb +15 -0
- data/spec/dummy/db/migrate/20140206173609_create_controlled_versioning_version_children.controlled_versioning.rb +19 -0
- data/spec/dummy/db/schema.rb +163 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/child_resources.rb +28 -0
- data/spec/factories/controlled_versioning_versions.rb +7 -0
- data/spec/factories/grand_child_resources.rb +17 -0
- data/spec/factories/parent_resources.rb +35 -0
- data/spec/factories/partially_exclusive_versionable_resources.rb +14 -0
- data/spec/factories/partially_inclusive_versionable_resources.rb +14 -0
- data/spec/factories/unversionable_resources.rb +14 -0
- data/spec/factories/users.rb +6 -0
- data/spec/factories/versionable_resources.rb +14 -0
- data/spec/spec_helper.rb +86 -0
- metadata +136 -11
- data/config/locales/en.yml +0 -4
- data/lib/generators/controlled_versioning/install_generator.rb +0 -30
- data/lib/generators/templates/create_version_attributes.rb +0 -17
- data/lib/generators/templates/create_version_children.rb +0 -20
- data/lib/generators/templates/create_versions.rb +0 -36
- data/lib/generators/templates/version.rb +0 -19
- data/lib/generators/templates/version_attribute.rb +0 -7
- data/lib/generators/templates/version_child.rb +0 -8
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDg0NzM1MTM3ZWQxODQ0NWE0OWFlYTlmZDYzOThjYThkOGUxYmY4ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzVkOTAwNTMxZWNkMDU0YzNmNzE5NmZhNTc1ZDk4ZGI4MmRhM2E1Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODY3N2JiYzZkMTI4NWQ1YWViODA0NjAzMmM4NjExM2QyYTdiNDc5ZDIxZjUz
|
10
|
+
NTliZmVmNTFlYWI4NzFhY2M3YTk0MWJjZGRlNDUzYTM3YzQ2MTRmMTQ0NmE0
|
11
|
+
MTk4MWVmYmE3NDQzMzYxN2RiYjFjOTU2OWZiMDdiOTZlOTgyYjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWJhOTE5MTNjNDkwM2JlZjNiYjM3ZTQxZTljZjYzNjRkZjlhYjY0OWUzMDc5
|
14
|
+
NmJmY2FiN2E0Zjk4NTU5MGI5NmE1Y2U1ODY1YzlkY2VmMmEwMjFjODU4MGEy
|
15
|
+
NmI0ZDc5MTQxNzhiYWVkMTJiOTE4NDdjY2YxODIxNjY5M2MyMjE=
|
data/MIT-LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ControlledVersioning
|
2
|
+
class Version < ActiveRecord::Base
|
3
|
+
belongs_to :versionable, polymorphic: true
|
4
|
+
belongs_to :user
|
5
|
+
has_many :version_attributes, as: :version
|
6
|
+
has_many :version_children, as: :version
|
7
|
+
|
8
|
+
validates :versionable, presence: true
|
9
|
+
|
10
|
+
scope :pending, -> { where(pending: true) }
|
11
|
+
scope :accepted, -> { where(accepted: true) }
|
12
|
+
scope :declined, -> { where(declined: true) }
|
13
|
+
|
14
|
+
def accept
|
15
|
+
Revision::Publisher.new(self).accept_revision unless initial?
|
16
|
+
update_attributes(pending: false, accepted: true)
|
17
|
+
end
|
18
|
+
|
19
|
+
def decline
|
20
|
+
update_attributes(pending: false, declined: true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ControlledVersioning</title>
|
5
|
+
<%= stylesheet_link_tag "controlled_versioning/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "controlled_versioning/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ControlledVersioning
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace ControlledVersioning
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module ControlledVersioning
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
config.generators do |g|
|
10
|
+
g.test_framework :rspec, :fixture => false
|
11
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
12
|
+
g.assets false
|
13
|
+
g.helper false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,316 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ControlledVersioning" do
|
4
|
+
|
5
|
+
it 'sets the initial version contributor if one is provided' do
|
6
|
+
user = create(:user)
|
7
|
+
resource = create(:versionable_resource, user: user)
|
8
|
+
expect(resource.initial_version.user).to eq user
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does not set the initial version contributor if one is not provided' do
|
12
|
+
resource = create(:versionable_resource)
|
13
|
+
expect(resource.initial_version.user).to be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets the revision contributor if they are provided' do
|
17
|
+
user = create(:user)
|
18
|
+
resource = create(:versionable_resource)
|
19
|
+
revision = resource.submit_revision(r_string: "new string",
|
20
|
+
r_float: 90.1, user: user)
|
21
|
+
expect(revision.user).to eq user
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'does not set the revision contributor if they are not provided' do
|
25
|
+
resource = create(:versionable_resource)
|
26
|
+
revision = resource.submit_revision(r_string: "new string",
|
27
|
+
r_float: 90.1)
|
28
|
+
expect(revision.user).to be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'writes initial version notes if they are provided' do
|
32
|
+
notes = "These are my notes"
|
33
|
+
resource = create(:versionable_resource, notes: notes)
|
34
|
+
expect(resource.initial_version.notes).to eq notes
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'does not write initial version notes if they are not provided' do
|
38
|
+
resource = create(:versionable_resource)
|
39
|
+
expect(resource.initial_version.notes).to be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'writes revision notes if they are provided' do
|
43
|
+
notes = "These are my notes"
|
44
|
+
resource = create(:versionable_resource)
|
45
|
+
revision = resource.submit_revision(r_string: "new string",
|
46
|
+
r_float: 90.1, notes: notes)
|
47
|
+
expect(revision.notes).to eq notes
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'does not write revision notes if they are not provided' do
|
51
|
+
resource = create(:versionable_resource)
|
52
|
+
revision = resource.submit_revision(r_string: "new string",
|
53
|
+
r_float: 90.1)
|
54
|
+
expect(revision.notes).to be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'has a scope that' do
|
58
|
+
before :each do
|
59
|
+
@resource = create(:versionable_resource)
|
60
|
+
@accepted_1 = @resource.submit_revision(r_string: "accepted 1")
|
61
|
+
@accepted_2 = @resource.submit_revision(r_string: "accepted 2")
|
62
|
+
@declined_1 = @resource.submit_revision(r_string: "declined 1")
|
63
|
+
@declined_2 = @resource.submit_revision(r_string: "declined 2")
|
64
|
+
@pending_1 = @resource.initial_version
|
65
|
+
@pending_2 = @resource.submit_revision(r_string: "pending 2")
|
66
|
+
@accepted_1.accept
|
67
|
+
@accepted_2.accept
|
68
|
+
@declined_1.decline
|
69
|
+
@declined_2.decline
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns an array of pending versions' do
|
73
|
+
expect(@resource.versions.pending).to match_array(
|
74
|
+
[@pending_1, @pending_2])
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns an array of accepted versions' do
|
78
|
+
expect(@resource.versions.accepted).to match_array(
|
79
|
+
[@accepted_1, @accepted_2])
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'returns an array of declined versions' do
|
83
|
+
expect(@resource.versions.declined).to match_array(
|
84
|
+
[@declined_1, @declined_2])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'by default' do
|
89
|
+
before :each do
|
90
|
+
@resource = create(:versionable_resource)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns a list of versionable attributes' do
|
94
|
+
expect(@resource.versionable_attributes).to eq(
|
95
|
+
@resource.attributes.except("id", "updated_at", "created_at"))
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'returns the initial version' do
|
99
|
+
@resource.versions.create
|
100
|
+
@resource.versions.create
|
101
|
+
expect(@resource.initial_version).to eq(
|
102
|
+
@resource.versions.find_by(initial: true))
|
103
|
+
end
|
104
|
+
|
105
|
+
it "rejects revisions with invalid changes" do
|
106
|
+
version = @resource.submit_revision(r_string: "new string",
|
107
|
+
r_float: 9000000.1)
|
108
|
+
expect(version).to have(1).error_on(:r_float)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "rejects revisions that make no changes" do
|
112
|
+
version = @resource.submit_revision(@resource.versionable_attributes)
|
113
|
+
expect(version).to have(1).error
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'handles revision' do
|
117
|
+
before :each do
|
118
|
+
@version = @resource.submit_revision(r_string: "new string",
|
119
|
+
r_float: 90.1)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'by creating versions with the suggested attributes' do
|
123
|
+
@resource.reload
|
124
|
+
r_string = @version.version_attributes.find_by(name: "r_string")
|
125
|
+
r_float = @version.version_attributes.find_by(name: "r_float")
|
126
|
+
expect(r_string.old_value).to eq("my string")
|
127
|
+
expect(r_string.new_value).to eq("new string")
|
128
|
+
expect(r_float.old_value).to eq("3.14")
|
129
|
+
expect(r_float.new_value).to eq("90.1")
|
130
|
+
expect(@resource.r_string).to eq("my string")
|
131
|
+
expect(@resource.r_float).to eq(3.14)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "by skipping non-revised attributes" do
|
135
|
+
expect(@version.version_attributes.find_by(name: "r_text")).to be_nil
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'by updating model data if its revisions are accepted' do
|
139
|
+
@version.accept
|
140
|
+
@resource.reload
|
141
|
+
@version.reload
|
142
|
+
expect(@resource.r_string).to eq "new string"
|
143
|
+
expect(@resource.r_float).to eq 90.1
|
144
|
+
expect(@version.pending).to eq false
|
145
|
+
expect(@version.declined).to eq false
|
146
|
+
expect(@version.accepted).to eq true
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'by maintaining model data if its revisions are declined' do
|
150
|
+
@version.decline
|
151
|
+
@resource.reload
|
152
|
+
@version.reload
|
153
|
+
expect(@resource.r_string).to eq "my string"
|
154
|
+
expect(@resource.r_float).to eq 3.14
|
155
|
+
expect(@version.pending).to eq false
|
156
|
+
expect(@version.declined).to eq true
|
157
|
+
expect(@version.accepted).to eq false
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'by not updating model data if the initial version is accepted' do
|
161
|
+
@version.accept
|
162
|
+
@resource.initial_version.accept
|
163
|
+
@resource.reload
|
164
|
+
expect(@resource.r_string).to eq "new string"
|
165
|
+
expect(@resource.r_float).to eq 90.1
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'with nested attributes' do
|
171
|
+
before :each do
|
172
|
+
@resource = create(:parent_with_grand_children)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'creates version children' do
|
176
|
+
expect(@resource.initial_version.version_children.length).to eq 3
|
177
|
+
expect(@resource.initial_version.version_children.last.version_children.
|
178
|
+
length).to eq 3
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'rejects invalid children' do
|
182
|
+
first_child_resource = @resource.child_resources.first
|
183
|
+
version = @resource.submit_revision(child_resources_attributes: [
|
184
|
+
{id: first_child_resource.id, r_float: 90000000000.6}
|
185
|
+
])
|
186
|
+
expect(version).to have(1).error
|
187
|
+
end
|
188
|
+
|
189
|
+
context 'handles revision' do
|
190
|
+
before :each do
|
191
|
+
@first_child_resource = @resource.child_resources[0]
|
192
|
+
@version = @resource.submit_revision(child_resources_attributes: [
|
193
|
+
{id: @first_child_resource.id, r_string: "new string"}
|
194
|
+
])
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'by creating versions for its children' do
|
198
|
+
expect(@version.version_children.length).to eq 1
|
199
|
+
changed_attribute = @version.version_children.
|
200
|
+
find_by(versionable: @first_child_resource).
|
201
|
+
version_attributes.find_by(name: "r_string")
|
202
|
+
expect(changed_attribute.new_value).to eq "new string"
|
203
|
+
expect(changed_attribute.old_value).to eq "my string"
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'by updating its children data if its revisions are approved' do
|
207
|
+
@version.accept
|
208
|
+
@first_child_resource.reload
|
209
|
+
expect(@first_child_resource.r_string).to eq "new string"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context 'handles revision for deeply nested children' do
|
214
|
+
before :each do
|
215
|
+
@first_child_resource = @resource.child_resources[0]
|
216
|
+
@first_grand_child_resource = @first_child_resource.
|
217
|
+
grand_child_resources.first
|
218
|
+
@version = @resource.submit_revision(child_resources_attributes: [
|
219
|
+
{id: @first_child_resource.id, grand_child_resources_attributes: [
|
220
|
+
{id: @first_grand_child_resource.id, r_string: "new string"}
|
221
|
+
]}
|
222
|
+
])
|
223
|
+
@child_version = @version.version_children.
|
224
|
+
find_by(versionable_id: @first_child_resource.id)
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'by creating versions for the full family' do
|
228
|
+
expect(@child_version.version_children.length).to eq 1
|
229
|
+
changed_attribute = @child_version.version_children.
|
230
|
+
find_by(versionable: @first_grand_child_resource).
|
231
|
+
version_attributes.find_by(name: "r_string")
|
232
|
+
expect(changed_attribute.new_value).to eq "new string"
|
233
|
+
expect(changed_attribute.old_value).to eq "my string"
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'by updating its deeply nested data if its revisions are approved' do
|
237
|
+
@version.accept
|
238
|
+
@first_grand_child_resource.reload
|
239
|
+
expect(@first_grand_child_resource.r_string).to eq "new string"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context 'handles new children' do
|
244
|
+
before :each do
|
245
|
+
@version = @resource.submit_revision(child_resources_attributes: [
|
246
|
+
{r_float: 14.0}
|
247
|
+
])
|
248
|
+
@child_version = @version.version_children.first
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'by creating version for new children' do
|
252
|
+
expect(@version.version_children.length).to eq 1
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'by creating attributes for new children' do
|
256
|
+
changed_attribute = @child_version.version_attributes.
|
257
|
+
find_by(name: "r_float")
|
258
|
+
expect(changed_attribute.new_value).to eq "14.0"
|
259
|
+
expect(changed_attribute.old_value).to be_nil
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'by creating new children when approved' do
|
263
|
+
@version.accept
|
264
|
+
@resource.reload
|
265
|
+
expect(@resource.child_resources.find_by(r_float: 14.0)).to_not be_nil
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
context 'handles child destruction' do
|
270
|
+
before :each do
|
271
|
+
@first_child_resource = @resource.child_resources[0]
|
272
|
+
@version = @resource.submit_revision(child_resources_attributes: [
|
273
|
+
{id: @first_child_resource.id, _destroy: "1"}
|
274
|
+
])
|
275
|
+
@child_version = @version.version_children.find_by(versionable_id:
|
276
|
+
@first_child_resource.id)
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'by creating a version for the marked child' do
|
280
|
+
expect(@version.version_children.length).to eq 1
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'by marking a resource for removal if _destroy is sent' do
|
284
|
+
expect(@child_version.marked_for_removal).to be true
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'by preserving a resource until its mark is approved' do
|
288
|
+
@first_child_resource.reload
|
289
|
+
expect(@first_child_resource).to be_an_instance_of(ChildResource)
|
290
|
+
end
|
291
|
+
|
292
|
+
it 'by removing a resource if its mark was approved' do
|
293
|
+
@version.accept
|
294
|
+
@resource.reload
|
295
|
+
expect(@resource.child_resources.length).to eq 2
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
context 'with versionable_attributes' do
|
301
|
+
it 'returns a list of versionable attributes' do
|
302
|
+
resource = create(:partially_inclusive_versionable_resource)
|
303
|
+
expect(resource.versionable_attributes).to eq(
|
304
|
+
resource.attributes.slice("r_boolean", "r_date"))
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context 'with nonversionable_attributes' do
|
309
|
+
it 'returns a list of versionable attributes' do
|
310
|
+
resource = create(:partially_exclusive_versionable_resource)
|
311
|
+
expect(resource.versionable_attributes).to eq(
|
312
|
+
resource.attributes.except("id", "updated_at", "created_at",
|
313
|
+
"r_boolean", "r_date"))
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|