protected_record 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/protected_record/use_case/update.rb +9 -2
- data/lib/protected_record/version.rb +1 -1
- data/protected_record.gemspec +1 -0
- data/test/minitest_helper.rb +2 -0
- data/test/protected_record/update_test.rb +17 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4927b67aac01a596ca4d94d19116081be1ada454
|
4
|
+
data.tar.gz: 19cd23eff4c9445f247ca0680ee9ea226516d999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2780b4ccd795fbf837318537d2a0d62072d94a0d2ee16871f813c24bac66878fc5cb05ec663edf715b37ca8f2a396c294880856f5a75de8b21b9cf5d1e0bcb58
|
7
|
+
data.tar.gz: 035114f30e0da8306ffd9bc56c539b3d38abf9f97545e9b497810049d889de6cb930008da9575eaefaeae3a13578e9c47a4e5ffa2a9003c69b4fc04149bc7ecd
|
@@ -7,7 +7,9 @@ module ProtectedRecord
|
|
7
7
|
options = {
|
8
8
|
change_request: UseCase::ChangeRequest::Create,
|
9
9
|
change_filter: UseCase::ChangeFilter::Create,
|
10
|
-
change_log: UseCase::ChangeLog::Create
|
10
|
+
change_log: UseCase::ChangeLog::Create,
|
11
|
+
change_request_record_class: ::ProtectedRecord::ChangeRequest::Record,
|
12
|
+
change_log_record_class: ::ProtectedRecord::ChangeLog::Record
|
11
13
|
}.merge!(options)
|
12
14
|
|
13
15
|
load_options(:params, :protected_record, :change_request, :change_log, :change_filter, :user, options)
|
@@ -39,6 +41,7 @@ module ProtectedRecord
|
|
39
41
|
@protected_record.attributes = @params
|
40
42
|
|
41
43
|
request_result = @change_request.new({
|
44
|
+
record_class: @change_request_record_class,
|
42
45
|
protected_keys: @protected_keys,
|
43
46
|
protected_record: @protected_record,
|
44
47
|
user: @user
|
@@ -66,7 +69,11 @@ module ProtectedRecord
|
|
66
69
|
end
|
67
70
|
|
68
71
|
def log_changes
|
69
|
-
log_result = @change_log.new(
|
72
|
+
log_result = @change_log.new({
|
73
|
+
user: @user,
|
74
|
+
changed_object: @protected_record,
|
75
|
+
record_class: @change_log_record_class
|
76
|
+
}).execute!
|
70
77
|
|
71
78
|
log_result.successful? ? return : raise
|
72
79
|
end
|
data/protected_record.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_runtime_dependency "pay_dirt", "~> 1.0.0"
|
29
29
|
s.add_runtime_dependency "activerecord"
|
30
30
|
|
31
|
+
s.add_development_dependency "coveralls"
|
31
32
|
s.add_development_dependency "minitest"
|
32
33
|
s.add_development_dependency "rake"
|
33
34
|
s.add_development_dependency "pry"
|
data/test/minitest_helper.rb
CHANGED
@@ -12,7 +12,9 @@ describe ProtectedRecord::Update do
|
|
12
12
|
@test_case = TestCase.new( knowledge: :power )
|
13
13
|
|
14
14
|
@dependencies = {
|
15
|
-
|
15
|
+
change_log_record_class: @change_log_record_class = MiniTest::Mock.new,
|
16
|
+
change_request_record_class: @change_request_record_class = MiniTest::Mock.new,
|
17
|
+
user: @user = MiniTest::Mock.new,
|
16
18
|
protected_record: @test_case,
|
17
19
|
protected_keys: [:knowledge],
|
18
20
|
}
|
@@ -41,4 +43,18 @@ describe ProtectedRecord::Update do
|
|
41
43
|
it "can be executed" do
|
42
44
|
@subject.new(@dependencies).must_respond_to :execute!
|
43
45
|
end
|
46
|
+
|
47
|
+
it "will be successful" do
|
48
|
+
@change_log_record_class.expect(:new, @clr_instance = MiniTest::Mock.new, [])
|
49
|
+
@change_request_record_class.expect(:new, @crr_instance = MiniTest::Mock.new, [])
|
50
|
+
@clr_instance.expect(:user=, @user, [@user])
|
51
|
+
@clr_instance.expect(:recordable=, @user, [@test_case])
|
52
|
+
@clr_instance.expect(:observed_changes=, "{\"knowledge\":[null,null]}", ["{\"knowledge\":[null,null]}"])
|
53
|
+
@clr_instance.expect(:save, true)
|
54
|
+
@crr_instance.expect(:user=, @user, [@user])
|
55
|
+
@crr_instance.expect(:recordable=, @test_case, [@test_case])
|
56
|
+
@crr_instance.expect(:requested_changes=, "{\"knowledge\":[null,\"power\"]}", ["{\"knowledge\":[null,\"power\"]}"])
|
57
|
+
@crr_instance.expect(:save, true)
|
58
|
+
assert @subject.new(@dependencies).execute!.successful?
|
59
|
+
end
|
44
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protected_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tad Hosford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pay_dirt
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|