mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Correct assumption of survey start and end dates
The logic used for the `:reply` ability incompletely duplicated that of
`Survey#active?` and incorrectly assumed that surveys always have start
and end dates.
Resolves:
Failures:
1) Survey as an attendee respond to a survey during registration
Failure/Error: survey.start_date > Time.current || survey.end_date < Time.current
ActionView::Template::Error:
undefined method `>' for nil:NilClass
survey.start_date > Time.current || survey.end_date < Time.current
^
# ./app/models/ability.rb:126:in `block in signed_in'
# ./app/views/surveys/show.html.haml:28:in `block in _app_views_surveys_show_html_haml___3404959267043700678_138180'
# ./app/views/surveys/show.html.haml:19:in `_app_views_surveys_show_html_haml___3404959267043700678_138180'
Failed examples:
rspec ./spec/features/surveys_spec.rb:37 # Survey as an attendee respond to a survey during registration
This commit is contained in:
parent
3e7be52586
commit
b565be2f46
2 changed files with 5 additions and 3 deletions
|
|
@ -122,9 +122,7 @@ class Ability
|
|||
# if not, do not allow replies.
|
||||
|
||||
# do not allow replies before the start_date or after the end_date of survey
|
||||
cannot :reply, Survey do |survey|
|
||||
survey.start_date > Time.current || survey.end_date < Time.current
|
||||
end
|
||||
cannot :reply, Survey, &:closed?
|
||||
|
||||
can [:destroy], Openid
|
||||
|
||||
|
|
|
|||
|
|
@ -32,4 +32,8 @@ class Survey < ActiveRecord::Base
|
|||
now <= end_date
|
||||
end
|
||||
end
|
||||
|
||||
def closed?
|
||||
!active?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue