File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ class School < ApplicationRecord
17
17
validates :creator_id , presence : true , uniqueness : true
18
18
validates :creator_agree_authority , presence : true , acceptance : true
19
19
validates :creator_agree_terms_and_conditions , presence : true , acceptance : true
20
+ validates :rejected_at , absence : { if : proc { |school | school . verified? } }
21
+ validates :verified_at , absence : { if : proc { |school | school . rejected? } }
20
22
21
23
before_validation :normalize_reference
22
24
Original file line number Diff line number Diff line change 177
177
school . creator_agree_terms_and_conditions = false
178
178
expect ( school ) . to be_invalid
179
179
end
180
+
181
+ it 'cannot have #rejected_at set when #verified_at is present' do
182
+ school . update! ( verified_at : Time . zone . now )
183
+ school . update ( rejected_at : Time . zone . now )
184
+ expect ( school . errors [ :rejected_at ] ) . to include ( 'must be blank' )
185
+ end
186
+
187
+ it 'cannot have #verified_at set when #rejected_at is present' do
188
+ school . update! ( rejected_at : Time . zone . now )
189
+ school . update ( verified_at : Time . zone . now )
190
+ expect ( school . errors [ :verified_at ] ) . to include ( 'must be blank' )
191
+ end
180
192
end
181
193
182
194
describe '#creator' do
You can’t perform that action at this time.
0 commit comments