hoodoo 2.7.0 → 2.8.0
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/lib/hoodoo/active/active_record/creator.rb +1 -4
- data/lib/hoodoo/version.rb +2 -2
- data/spec/active/active_record/creator_spec.rb +51 -76
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8faac53f6f7027ef0eb75a9bbf911b3206914880261b44be9cef926b6449623b
|
4
|
+
data.tar.gz: 2e285f61106912bb90aa10f251bcd36d284d649c8199270cb75f8232562a0472
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c47a9c16545aac86f9ddb7af7017aab704a106427f6dfae2e091d081ba999861dfa35cefe7a820b82d3c62d651dc070a2d43630c8134e043d33fcd365e0f769
|
7
|
+
data.tar.gz: a7db2209730adaa2dd3235a4ac66c21b4194f3135ef585f75e957e484258100636532b458a88bd83188107efc9b66610cc925184d397822162e009820233797d
|
@@ -120,10 +120,7 @@ module Hoodoo
|
|
120
120
|
# things we currently require - set "created_at"/"updated_at".
|
121
121
|
#
|
122
122
|
unless context.request.dated_from.nil?
|
123
|
-
instance.created_at = instance.updated_at = context.request.dated_from
|
124
|
-
( self.include?( Hoodoo::ActiveRecord::Dated ) && self.dating_enabled?() ) ||
|
125
|
-
( self.include?( Hoodoo::ActiveRecord::ManuallyDated ) && self.manual_dating_enabled?() )
|
126
|
-
)
|
123
|
+
instance.created_at = instance.updated_at = context.request.dated_from
|
127
124
|
end
|
128
125
|
|
129
126
|
return instance
|
data/lib/hoodoo/version.rb
CHANGED
@@ -12,11 +12,11 @@ module Hoodoo
|
|
12
12
|
# The Hoodoo gem version. If this changes, be sure to re-run
|
13
13
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
14
14
|
#
|
15
|
-
VERSION = '2.
|
15
|
+
VERSION = '2.8.0'
|
16
16
|
|
17
17
|
# The Hoodoo gem date. If this changes, be sure to re-run
|
18
18
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
19
19
|
#
|
20
|
-
DATE = '2018-08-
|
20
|
+
DATE = '2018-08-07'
|
21
21
|
|
22
22
|
end
|
@@ -2,6 +2,25 @@ require 'spec_helper'
|
|
2
2
|
require 'active_record'
|
3
3
|
|
4
4
|
describe Hoodoo::ActiveRecord::Creator do
|
5
|
+
|
6
|
+
class RSpecModelCreatorTest < ActiveRecord::Base
|
7
|
+
include Hoodoo::ActiveRecord::Creator
|
8
|
+
end
|
9
|
+
|
10
|
+
class RSpecModelCreatorTestManuallyDated < ActiveRecord::Base
|
11
|
+
self.table_name = :r_spec_model_creator_tests
|
12
|
+
|
13
|
+
include Hoodoo::ActiveRecord::Creator
|
14
|
+
include Hoodoo::ActiveRecord::ManuallyDated
|
15
|
+
end
|
16
|
+
|
17
|
+
class RSpecModelCreatorTestAutoDated < ActiveRecord::Base
|
18
|
+
self.table_name = :r_spec_model_creator_tests
|
19
|
+
|
20
|
+
include Hoodoo::ActiveRecord::Creator
|
21
|
+
include Hoodoo::ActiveRecord::Dated
|
22
|
+
end
|
23
|
+
|
5
24
|
before :all do
|
6
25
|
spec_helper_silence_stdout() do
|
7
26
|
ActiveRecord::Migration.create_table( :r_spec_model_creator_tests, :id => :string ) do | t |
|
@@ -11,19 +30,12 @@ describe Hoodoo::ActiveRecord::Creator do
|
|
11
30
|
t.timestamps :null => true
|
12
31
|
end
|
13
32
|
end
|
14
|
-
|
15
|
-
class RSpecModelCreatorTest < ActiveRecord::Base
|
16
|
-
include Hoodoo::ActiveRecord::Creator
|
17
|
-
include Hoodoo::ActiveRecord::Dated
|
18
|
-
include Hoodoo::ActiveRecord::ManuallyDated
|
19
|
-
end
|
20
33
|
end
|
21
34
|
|
22
35
|
# ==========================================================================
|
23
36
|
|
24
37
|
context 'new_in' do
|
25
38
|
before :each do
|
26
|
-
|
27
39
|
# Get a good-enough-for-test interaction which has a context
|
28
40
|
# that contains a Session we can modify.
|
29
41
|
|
@@ -39,94 +51,57 @@ describe Hoodoo::ActiveRecord::Creator do
|
|
39
51
|
@session = @interaction.context.session
|
40
52
|
end
|
41
53
|
|
42
|
-
|
43
|
-
|
54
|
+
shared_examples 'Creator-enabled model' do | klass |
|
55
|
+
it 'creates with no special values' do
|
56
|
+
instance = klass.new_in( @context )
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
expect( instance.created_at ).to be_nil
|
59
|
+
expect( instance.updated_at ).to be_nil
|
60
|
+
end
|
48
61
|
|
49
|
-
|
50
|
-
before :each do
|
62
|
+
it 'creates with given values' do
|
51
63
|
@time = Time.now
|
52
64
|
@context.request.dated_from = @time
|
53
|
-
end
|
54
65
|
|
55
|
-
|
56
|
-
it 'using the specified dated-from value' do
|
57
|
-
instance = RSpecModelCreatorTest.new_in( @context )
|
66
|
+
instance = klass.new_in( @context )
|
58
67
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
68
|
+
expect( instance.created_at ).to eq( @time )
|
69
|
+
expect( instance.updated_at ).to eq( @time )
|
62
70
|
end
|
63
71
|
|
64
|
-
|
65
|
-
|
66
|
-
instance = RSpecModelCreatorTest.new_in( @context )
|
72
|
+
it 'creates with provided attributes' do
|
73
|
+
instance = klass.new_in( @context, code: 'code', field_one: 'one' )
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
75
|
+
expect( instance.code ).to eq( 'code' )
|
76
|
+
expect( instance.field_one ).to eq( 'one' )
|
71
77
|
end
|
72
78
|
|
73
|
-
|
74
|
-
context
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
it_behaves_like 'a dated model'
|
79
|
+
it 'creates with a block' do
|
80
|
+
instance = klass.new_in( @context ) do | i |
|
81
|
+
i.code = 'code'
|
82
|
+
i.field_one = 'one'
|
80
83
|
end
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
+
expect( instance.code ).to eq( 'code' )
|
86
|
+
expect( instance.field_one ).to eq( 'one' )
|
85
87
|
end
|
86
88
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
# Technically ActiveRecord documentation seems to indicate this is an
|
90
|
+
# either-or choice, but the code certainly supports both and it isn't
|
91
|
+
# *explicitly* stated as such, so we assume both can be mixed here.
|
92
|
+
#
|
93
|
+
it 'creates with provided attributes and a block' do
|
94
|
+
instance = klass.new_in( @context, code: 'code' ) do | i |
|
95
|
+
i.field_one = 'one'
|
94
96
|
end
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
end
|
98
|
+
expect( instance.code ).to eq( 'code' )
|
99
|
+
expect( instance.field_one ).to eq( 'one' )
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
expect( instance.code ).to eq( 'code' )
|
106
|
-
expect( instance.field_one ).to eq( 'one' )
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'creates with a block' do
|
110
|
-
instance = RSpecModelCreatorTest.new_in( @context ) do | i |
|
111
|
-
i.code = 'code'
|
112
|
-
i.field_one = 'one'
|
113
|
-
end
|
114
|
-
|
115
|
-
expect( instance.code ).to eq( 'code' )
|
116
|
-
expect( instance.field_one ).to eq( 'one' )
|
117
|
-
end
|
118
|
-
|
119
|
-
# Technically ActiveRecord documentation seems to indicate this is an
|
120
|
-
# either-or choice, but the code certainly supports both and it isn't
|
121
|
-
# *explicitly* stated as such, so we assume both can be mixed here.
|
122
|
-
#
|
123
|
-
it 'creates with provided attributes and a block' do
|
124
|
-
instance = RSpecModelCreatorTest.new_in( @context, code: 'code' ) do | i |
|
125
|
-
i.field_one = 'one'
|
126
|
-
end
|
127
|
-
|
128
|
-
expect( instance.code ).to eq( 'code' )
|
129
|
-
expect( instance.field_one ).to eq( 'one' )
|
130
|
-
end
|
103
|
+
it_behaves_like 'Creator-enabled model', RSpecModelCreatorTest
|
104
|
+
it_behaves_like 'Creator-enabled model', RSpecModelCreatorTestManuallyDated
|
105
|
+
it_behaves_like 'Creator-enabled model', RSpecModelCreatorTestAutoDated
|
131
106
|
end
|
132
107
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rack
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: dalli
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '1.1'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: alchemy-flux
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.2.1
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.2.1
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: rspec
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|