mongoid_immutable_fields 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,6 +19,18 @@ describe Mongoid::ImmutableFields do
19
19
 
20
20
  end
21
21
 
22
+ describe 'when persisting a document with immutable fields and an after_create call that re-saves the document' do
23
+ before(:each) do
24
+ @dummy = DummyDocumentAfterCreate.new(:name => 'Test', :description => 'Test document.', :reference_id => 'abc123')
25
+ end
26
+
27
+ it 'should be persisted normally' do
28
+ # Right now the only way for this to work is to actually execute a self.reload as the first step in an after_create.
29
+ @dummy.save.should eq true
30
+ @dummy.errors.should be_empty
31
+ end
32
+ end
33
+
22
34
  describe 'when updating a document with immutable fields' do
23
35
 
24
36
  before(:each) do
@@ -0,0 +1,19 @@
1
+ class DummyDocumentAfterCreate
2
+ include Mongoid::Document
3
+ include Mongoid::ImmutableFields
4
+
5
+ field :name
6
+ field :description
7
+ field :reference_id
8
+
9
+ immutable_fields :name, :reference_id
10
+
11
+ after_create :change_field_and_save_again
12
+
13
+ def change_field_and_save_again
14
+ self.reload
15
+ self.description = 'New desc'
16
+ self.safely.save
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_immutable_fields
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-17 00:00:00.000000000Z
12
+ date: 2012-03-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70245287878100 !ruby/object:Gem::Requirement
16
+ requirement: &70138187896040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70245287878100
24
+ version_requirements: *70138187896040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jeweler
27
- requirement: &70245287877580 !ruby/object:Gem::Requirement
27
+ requirement: &70138187895000 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.5.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70245287877580
35
+ version_requirements: *70138187895000
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70245287876820 !ruby/object:Gem::Requirement
38
+ requirement: &70138187894000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70245287876820
46
+ version_requirements: *70138187894000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: shoulda
49
- requirement: &70245287876000 !ruby/object:Gem::Requirement
49
+ requirement: &70138187892900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70245287876000
57
+ version_requirements: *70138187892900
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mongo
60
- requirement: &70245287875180 !ruby/object:Gem::Requirement
60
+ requirement: &70138187892140 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - =
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.3.1
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70245287875180
68
+ version_requirements: *70138187892140
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mongo_ext
71
- requirement: &70245287874340 !ruby/object:Gem::Requirement
71
+ requirement: &70138187891500 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,21 +76,21 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70245287874340
79
+ version_requirements: *70138187891500
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: mongoid
82
- requirement: &70245287873680 !ruby/object:Gem::Requirement
82
+ requirement: &70138187890360 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - =
86
86
  - !ruby/object:Gem::Version
87
- version: 2.4.3
87
+ version: 2.4.4
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70245287873680
90
+ version_requirements: *70138187890360
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bson_ext
93
- requirement: &70245287873060 !ruby/object:Gem::Requirement
93
+ requirement: &70138187889700 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '1.3'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70245287873060
101
+ version_requirements: *70138187889700
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: database_cleaner
104
- requirement: &70245287872540 !ruby/object:Gem::Requirement
104
+ requirement: &70138187888820 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70245287872540
112
+ version_requirements: *70138187888820
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: mongo
115
- requirement: &70245287872000 !ruby/object:Gem::Requirement
115
+ requirement: &70138187887820 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - =
@@ -120,18 +120,18 @@ dependencies:
120
120
  version: 1.3.1
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70245287872000
123
+ version_requirements: *70138187887820
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: mongoid
126
- requirement: &70245287871480 !ruby/object:Gem::Requirement
126
+ requirement: &70138187887200 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - =
130
130
  - !ruby/object:Gem::Version
131
- version: 2.4.3
131
+ version: 2.4.4
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70245287871480
134
+ version_requirements: *70138187887200
135
135
  description: Prevent fields from being updated by including a mongoid module and marking
136
136
  the fields as immutable.
137
137
  email: jeff.bozek@gmail.com
@@ -149,6 +149,7 @@ files:
149
149
  - spec/immutable_fields_spec.rb
150
150
  - spec/spec_helper.rb
151
151
  - spec/support/dummy_document.rb
152
+ - spec/support/dummy_document_after_create.rb
152
153
  homepage: http://github.com/jeffbozek/mongoid_immutable_fields
153
154
  licenses:
154
155
  - MIT
@@ -164,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
165
  version: '0'
165
166
  segments:
166
167
  - 0
167
- hash: 2347292288252551569
168
+ hash: -4390341359582650231
168
169
  required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  none: false
170
171
  requirements:
@@ -181,3 +182,4 @@ test_files:
181
182
  - spec/immutable_fields_spec.rb
182
183
  - spec/spec_helper.rb
183
184
  - spec/support/dummy_document.rb
185
+ - spec/support/dummy_document_after_create.rb