Les heures de soumission et de validation d'evt étaient mal gérées
This commit is contained in:
parent
c6ab829578
commit
e866578b9e
@ -32,8 +32,8 @@ class Event < ActiveRecord::Base
|
|||||||
|
|
||||||
|
|
||||||
before_validation on: :create do
|
before_validation on: :create do
|
||||||
self.submission_time = Date.today
|
self.submission_time = DateTime.now
|
||||||
self.decision_time = Date.today
|
self.decision_time = DateTime.now
|
||||||
|
|
||||||
if self.submitter.empty?
|
if self.submitter.empty?
|
||||||
self.submitter = self.contact
|
self.submitter = self.contact
|
||||||
@ -46,6 +46,12 @@ class Event < ActiveRecord::Base
|
|||||||
self.submitter_mail_id = SecureRandom.urlsafe_base64(32)[0...32]
|
self.submitter_mail_id = SecureRandom.urlsafe_base64(32)[0...32]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before_update do
|
||||||
|
if moderated? and moderated_was != moderated
|
||||||
|
self.decision_time = DateTime.now
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def same_day?
|
def same_day?
|
||||||
start_time.to_date == end_time.to_date
|
start_time.to_date == end_time.to_date
|
||||||
end
|
end
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
=l event.end_time, format: :at
|
=l event.end_time, format: :at
|
||||||
%td= event.city
|
%td= event.city
|
||||||
%td= event.related_region.name
|
%td= event.related_region.name
|
||||||
%td= time_ago_in_words event.submission_time.to_date
|
%td= time_ago_in_words event.submission_time
|
||||||
%th.actions
|
%th.actions
|
||||||
= link_to edit_moderation_path event do
|
= link_to edit_moderation_path event do
|
||||||
%em.fa.fa-pencil
|
%em.fa.fa-pencil
|
||||||
|
@ -18,10 +18,20 @@ class ModerationsControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
test 'should accept event' do
|
test 'should accept event' do
|
||||||
|
@moderation = events :proposed
|
||||||
|
|
||||||
|
decision = @moderation.decision_time
|
||||||
|
assert !@moderation.moderated?
|
||||||
|
|
||||||
|
assert_difference 'Event.moderated.count' do
|
||||||
put :accept, id: @moderation
|
put :accept, id: @moderation
|
||||||
|
end
|
||||||
|
|
||||||
assert assigns(:moderation).moderated?
|
assert assigns(:moderation).moderated?
|
||||||
assert_empty assigns(:moderation).errors
|
assert_empty assigns(:moderation).errors
|
||||||
|
|
||||||
|
assert decision < assigns(:moderation).decision_time
|
||||||
|
|
||||||
assert_redirected_to moderations_path
|
assert_redirected_to moderations_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
19
test/fixtures/events.yml
vendored
19
test/fixtures/events.yml
vendored
@ -37,3 +37,22 @@ two:
|
|||||||
submission_time: 2013-12-28 16:04:56
|
submission_time: 2013-12-28 16:04:56
|
||||||
moderator_mail_id: MyString
|
moderator_mail_id: MyString
|
||||||
submitter_mail_id: MyString
|
submitter_mail_id: MyString
|
||||||
|
|
||||||
|
proposed:
|
||||||
|
title: MyString
|
||||||
|
description: MyText
|
||||||
|
start_time: 2013-12-28 16:04:56
|
||||||
|
end_time: 2013-12-28 16:04:56
|
||||||
|
city: city_two.name
|
||||||
|
related_region: region_two
|
||||||
|
locality: 1
|
||||||
|
url: http://exemple.com
|
||||||
|
contact: test2@example.com
|
||||||
|
submitter: test2@example.com
|
||||||
|
moderated: 0
|
||||||
|
tags: MyString
|
||||||
|
secret: MyString
|
||||||
|
decision_time: 2013-12-28 16:04:56
|
||||||
|
submission_time: 2013-12-28 16:04:56
|
||||||
|
moderator_mail_id: MyString
|
||||||
|
submitter_mail_id: MyString
|
||||||
|
@ -48,4 +48,24 @@ class EventTest < ActiveSupport::TestCase
|
|||||||
@event.url = 'http:/truc.com'
|
@event.url = 'http:/truc.com'
|
||||||
assert !@event.valid?, @event.errors.messages
|
assert !@event.valid?, @event.errors.messages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test 'moderation' do
|
||||||
|
@event = Event.new(
|
||||||
|
title: 'hello world',
|
||||||
|
start_time: Time.new(),
|
||||||
|
end_time: Time.new() + 1,
|
||||||
|
description: 'et hop!',
|
||||||
|
city: City.first(),
|
||||||
|
related_region: Region.first(),
|
||||||
|
url: 'http://example.com',
|
||||||
|
contact: 'contact@example.com'
|
||||||
|
)
|
||||||
|
|
||||||
|
assert @event.save(), @event.errors.messages
|
||||||
|
assert !@event.moderated?
|
||||||
|
|
||||||
|
@event.update(moderated: 1)
|
||||||
|
|
||||||
|
assert @event.moderated?, @event.errors.messages
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user