approval2 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/approval2/controller_additions.rb +4 -4
- data/lib/approval2/model_additions.rb +17 -20
- data/lib/approval2/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZjBkNzAwZTMxODdhODEwNzQ5OWQ0YzNiNTBiMjkxNDg0NzA3MjVkZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 63eb8f62ec9ef31d1b8e8ae748720d6f3625e4e5
|
4
|
+
data.tar.gz: d94a300234cc6afc0b0eb2e2d7fa996a5ec842b9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTZlZGNiZWFlMzY5MzAzNjQ2MTExNGRkZWU5YmQ0YTk4MDQ3MDk2Y2MwNjFj
|
11
|
-
OTY2MWFhN2U1YjM2ODEzMTAzNGM5NWIwNjRkMjczNjIyNWNhZjU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGZiYzM0NDc3ZDBjMjcyNmFmZDEyMGQ5NGU5YTY1NWM0OGQ2NTA4ODY5NzJk
|
14
|
-
NmMxNjE3NGMyZTMzNDk0ZDkzMWNlOTI0NGE3MTA2M2MwN2MyYzJmOGRhMGY0
|
15
|
-
NDA3MGIyN2EyZDIzYWFjNTg5NjQ0OTNlOTRkNWRmNTg5YWNkM2U=
|
6
|
+
metadata.gz: 26c6e7d9d25aa4499db102f5a4009c636172f15cb0da272d460349cc3cd8ca81bddf1dcb2de143aa221c33f583dcf912f6a673517272004e288e4eecca61a38c
|
7
|
+
data.tar.gz: 8d41f124ba55c670e496532e358037e5aef16ee974248d2bf1b2433b6d7c7040ca0735554e78b2879461817360d259e2fe40f4257a914405600ab5d4cc0d86b7
|
@@ -38,13 +38,13 @@ module Approval2
|
|
38
38
|
modelName = self.class.name.sub("Controller", "").underscore.split('/').last.singularize
|
39
39
|
modelKlass = modelName.classify.constantize
|
40
40
|
|
41
|
-
x = modelKlass.unscoped.find(params[:id])
|
41
|
+
x = modelKlass.unscoped.find(params[:id])
|
42
42
|
modelKlass.transaction do
|
43
|
-
|
44
|
-
if
|
43
|
+
approved_record = x.approve
|
44
|
+
if approved_record.save
|
45
45
|
flash[:alert] = "#{modelName.humanize.titleize} record was approved successfully"
|
46
46
|
else
|
47
|
-
msg =
|
47
|
+
msg = approved_record.errors.full_messages
|
48
48
|
flash[:alert] = msg
|
49
49
|
raise ActiveRecord::Rollback
|
50
50
|
end
|
@@ -43,27 +43,24 @@ module Approval2
|
|
43
43
|
if self.approved_record.nil?
|
44
44
|
# create action, all we need to do is set the status to approved
|
45
45
|
self.approval_status = 'A'
|
46
|
-
self
|
47
|
-
else
|
48
|
-
# copy all attributes of the U record to the A record, and delete the U record
|
49
|
-
attributes = self.attributes.select do |attr, value|
|
50
|
-
self.class.column_names.include?(attr.to_s) and
|
51
|
-
['id', 'approved_id', 'approval_status', 'lock_version', 'approved_version', 'created_at', 'updated_at', 'updated_by', 'created_by'].exclude?(attr)
|
52
|
-
end
|
53
|
-
|
54
|
-
self.class.unscoped do
|
55
|
-
approved_record = self.approved_record
|
56
|
-
approved_record.assign_attributes(attributes)
|
57
|
-
approved_record.last_action = 'U'
|
58
|
-
approved_record.updated_by = self.created_by
|
59
|
-
self.destroy
|
60
|
-
# not enought time to test cases where the approval is being done after changes in validations of the model, such that the saving of the approved
|
61
|
-
# record fails, this can be fixed to return the errors so that they can be shown to the user
|
62
|
-
approved_record.save!
|
63
|
-
end
|
46
|
+
return self
|
64
47
|
end
|
65
|
-
|
66
|
-
|
48
|
+
|
49
|
+
# edit action
|
50
|
+
# copy all attributes of the U record to the A record, and delete the U record
|
51
|
+
attributes = self.attributes.select do |attr, value|
|
52
|
+
self.class.column_names.include?(attr.to_s) and
|
53
|
+
['id', 'approved_id', 'approval_status', 'lock_version', 'approved_version', 'created_at', 'updated_at', 'updated_by', 'created_by'].exclude?(attr)
|
54
|
+
end
|
55
|
+
|
56
|
+
self.class.unscoped do
|
57
|
+
approved_record = self.approved_record
|
58
|
+
approved_record.assign_attributes(attributes)
|
59
|
+
approved_record.last_action = 'U'
|
60
|
+
approved_record.updated_by = self.created_by
|
61
|
+
self.destroy
|
62
|
+
return approved_record
|
63
|
+
end
|
67
64
|
end
|
68
65
|
|
69
66
|
def enable_approve_button?
|
data/lib/approval2/version.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: approval2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akil
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.13'
|
20
20
|
type: :development
|
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: '1.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
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: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: audited
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: will_paginate
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
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: '0'
|
69
69
|
description:
|
@@ -73,7 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
76
|
+
- ".gitignore"
|
77
77
|
- CODE_OF_CONDUCT.md
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE.txt
|
@@ -103,17 +103,17 @@ require_paths:
|
|
103
103
|
- lib
|
104
104
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- -
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
110
|
requirements:
|
111
|
-
- -
|
111
|
+
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.4.
|
116
|
+
rubygems_version: 2.4.6
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: Enable the approval pattern for an AR model
|