flexible_enum 0.4.1 → 0.4.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/flexible_enum/setter_method_configurator.rb +1 -1
- data/lib/flexible_enum/version.rb +1 -1
- data/spec/setter_methods_spec.rb +32 -2
- data/spec/spec_helper.rb +4 -0
- metadata +13 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94d3ef232899f6e7411f802a9f61afbb1b00e510
|
4
|
+
data.tar.gz: 9c833016c20aa62ede9032c45a81b370ad39c78c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89a11ef2c046e548ce26ecfb752c2f7ed3c6df57b75136d39709ce4b0d7c4c50338d4d26d117011b92b5fc1e4f560f303ea949a887671156e179ae71a27c2267
|
7
|
+
data.tar.gz: faf22cccc8b2e56ef86e15eb1932abf2af07f738f59cd6079dd73891fa6ef878ae36910b886691944eaa9bc4773a2bd94247e0ebaf6435ad839e5e9ac382f3ef
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
Current release (in development)
|
2
2
|
--------------------------------
|
3
3
|
|
4
|
-
|
4
|
+
0.4.2
|
5
|
+
-----
|
6
|
+
|
7
|
+
* Enum setter methods raise exceptions in accordance with Rails conventions for bang (`!`) methods. #27
|
8
|
+
|
9
|
+
*Adam Prescott*
|
5
10
|
|
6
11
|
0.4.1
|
7
12
|
-----
|
@@ -9,6 +14,7 @@ Current release (in development)
|
|
9
14
|
* Add support for Rails 5. #33
|
10
15
|
|
11
16
|
*Alex Robbin*
|
17
|
+
|
12
18
|
* Add inverse scopes. #32
|
13
19
|
|
14
20
|
*Zach Fletcher*
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -355,4 +355,4 @@ Please see [CONTRIBUTING.md](https://github.com/meyouhealth/flexible_enum/blob/m
|
|
355
355
|
|
356
356
|

|
357
357
|
|
358
|
-
FlexibleEnum is maintained by
|
358
|
+
FlexibleEnum is maintained by MYH, Inc.
|
@@ -12,7 +12,7 @@ module FlexibleEnum
|
|
12
12
|
time = Time.now.utc
|
13
13
|
attributes["#{timestamp_attribute_name}_on".to_sym] = time.to_date if self.class.attribute_method?("#{timestamp_attribute_name}_on")
|
14
14
|
attributes["#{timestamp_attribute_name}_at".to_sym] = time if self.class.attribute_method?("#{timestamp_attribute_name}_at")
|
15
|
-
update_attributes(attributes)
|
15
|
+
update_attributes!(attributes)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/spec/setter_methods_spec.rb
CHANGED
@@ -3,6 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe "setter methods" do
|
4
4
|
subject(:register) { CashRegister.new }
|
5
5
|
|
6
|
+
before { register.save! }
|
7
|
+
|
6
8
|
it "adds default bang methods for setting a new value" do
|
7
9
|
expect(register.status).to be_nil
|
8
10
|
register.active!
|
@@ -20,29 +22,57 @@ describe "setter methods" do
|
|
20
22
|
end
|
21
23
|
|
22
24
|
describe "updating database" do
|
23
|
-
let!(:now) { Time.now }
|
25
|
+
let!(:now) { Time.at(Time.now.to_i) }
|
24
26
|
let(:updates) { [] }
|
25
27
|
|
26
28
|
before { allow(Time).to receive(:now).and_return(now) }
|
27
29
|
|
28
|
-
it "
|
30
|
+
it "performs an update on the relevant attribute" do
|
29
31
|
register.active!
|
30
32
|
register.close!
|
31
33
|
|
34
|
+
register.reload
|
35
|
+
|
32
36
|
expect(register).to be_active
|
33
37
|
expect(register).to be_closed
|
34
38
|
end
|
35
39
|
|
36
40
|
it "updates default timestamp columns with the current date and time" do
|
37
41
|
register.fill!
|
42
|
+
|
43
|
+
register.reload
|
44
|
+
|
38
45
|
expect(register).to be_full
|
39
46
|
expect(register.full_at).to eq(now)
|
40
47
|
end
|
41
48
|
|
42
49
|
it "updates custom timestamp columns with the current date and time" do
|
43
50
|
register.empty!
|
51
|
+
|
52
|
+
register.reload
|
53
|
+
|
44
54
|
expect(register).to be_empty
|
45
55
|
expect(register.emptied_at).to eq(now)
|
46
56
|
end
|
57
|
+
|
58
|
+
context "when there are validation errors" do
|
59
|
+
before { register.include_validations = true }
|
60
|
+
|
61
|
+
specify { expect(register).to_not be_valid }
|
62
|
+
|
63
|
+
it "raises and does not persist any changes" do
|
64
|
+
expect { register.empty! }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Required attribute can't be blank")
|
65
|
+
expect { register.close! }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Required attribute can't be blank")
|
66
|
+
|
67
|
+
expect(register).to be_empty
|
68
|
+
expect(register).to be_closed
|
69
|
+
|
70
|
+
register.reload
|
71
|
+
|
72
|
+
expect(register).to_not be_empty
|
73
|
+
expect(register).to_not be_closed
|
74
|
+
expect(register.emptied_at).to be_nil
|
75
|
+
end
|
76
|
+
end
|
47
77
|
end
|
48
78
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexible_enum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Daubert
|
8
8
|
- Alex Robbin
|
9
|
-
- Matthew Daubert
|
10
9
|
- Adam Prescott
|
10
|
+
- Matthew Daubert
|
11
11
|
- Alex Robbin
|
12
12
|
- Sean Santry
|
13
13
|
- Chad Dressler
|
14
14
|
- Adam Prescott
|
15
|
-
- Zach Fletcher
|
16
15
|
- David Larrabee
|
17
16
|
- Sean Santry
|
18
|
-
-
|
17
|
+
- Zach Fletcher
|
18
|
+
- Alex Robbin
|
19
|
+
- Bolek
|
19
20
|
- David C. Goldhirsch
|
20
21
|
- Guillermo Guerini
|
21
22
|
- Matthew Daubert
|
23
|
+
- jon.zeppieri
|
22
24
|
autorequire:
|
23
25
|
bindir: bin
|
24
26
|
cert_chain: []
|
25
|
-
date:
|
27
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
26
28
|
dependencies:
|
27
29
|
- !ruby/object:Gem::Dependency
|
28
30
|
name: activesupport
|
@@ -140,19 +142,21 @@ description: Helpers for enum-like fields
|
|
140
142
|
email:
|
141
143
|
- matt.daubert@meyouhealth.com
|
142
144
|
- alex.robbin@meyouhealth.com
|
143
|
-
- mdaubert@gmail.com
|
144
145
|
- adam@aprescott.com
|
146
|
+
- mdaubert@gmail.com
|
145
147
|
- alex@robbinsweb.biz
|
146
148
|
- sean.santry@meyouhealth.com
|
147
149
|
- chad@dresslerfamily.com
|
148
150
|
- adam.prescott@meyouhealth.com
|
149
|
-
- zach.fletcher@meyouhealth.com
|
150
151
|
- david.larrabee@meyouhealth.com
|
151
152
|
- sean@seansantry.com
|
152
|
-
-
|
153
|
+
- zach.fletcher@meyouhealth.com
|
154
|
+
- agrobbin@users.noreply.github.com
|
155
|
+
- bolek@meyouhealth.com
|
153
156
|
- dgoldhirsch@yahoo.com
|
154
157
|
- guillermo@gguerini.com
|
155
158
|
- mdaubert+github@gmail.com
|
159
|
+
- jon.zeppieri@meyouhealth.com
|
156
160
|
executables: []
|
157
161
|
extensions: []
|
158
162
|
extra_rdoc_files: []
|
@@ -211,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
215
|
version: '0'
|
212
216
|
requirements: []
|
213
217
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.6.11
|
215
219
|
signing_key:
|
216
220
|
specification_version: 4
|
217
221
|
summary: Helpers for enum-like fields
|