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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 261435611285df8117f8eb4507968098af93009c
4
- data.tar.gz: b1cfddfb7d6e0829f8864ff2794619a2bb58bf59
3
+ metadata.gz: 94d3ef232899f6e7411f802a9f61afbb1b00e510
4
+ data.tar.gz: 9c833016c20aa62ede9032c45a81b370ad39c78c
5
5
  SHA512:
6
- metadata.gz: 8768a09ca2910c8d36ebb3eb155702158ed6f74cce6d8f9b4e0a02a0d0248c648839c06c4fa4ee3ab39d74ce0b1eead390459c7701b882ac5dfcac8041417419
7
- data.tar.gz: b30f0f5dbbe17899be3e5b2beb7602d11fc310bc25c1a6dfed034357a5433d37ef1bf8688941ff8da7297559f80c697f40daca53ed66c4bf13cb2a86ab394607
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013–2015 MeYou Health
1
+ Copyright (c) 2013–2016 MYH, Inc.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -355,4 +355,4 @@ Please see [CONTRIBUTING.md](https://github.com/meyouhealth/flexible_enum/blob/m
355
355
 
356
356
  ![http://meyouhealth.com/](https://avatars3.githubusercontent.com/u/249181?v=3&s=200)
357
357
 
358
- FlexibleEnum is maintained by MeYou Health, LLC.
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
@@ -1,3 +1,3 @@
1
1
  module FlexibleEnum
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -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 "immediately dispatches a validation-free update" do
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
@@ -42,4 +42,8 @@ class CashRegister < ActiveRecord::Base
42
42
  honeywell "HON"
43
43
  sharp "SHCAY"
44
44
  end
45
+
46
+ attr_accessor :include_validations, :required_attribute
47
+
48
+ validates_presence_of :required_attribute, if: -> { include_validations }
45
49
  end
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.1
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
- - jon.zeppieri
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: 2016-04-15 00:00:00.000000000 Z
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
- - jon.zeppieri@meyouhealth.com
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.5.1
218
+ rubygems_version: 2.6.11
215
219
  signing_key:
216
220
  specification_version: 4
217
221
  summary: Helpers for enum-like fields