mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
created comments with FactoryGirl
This commit is contained in:
parent
b6d726d40e
commit
eab2894fad
5 changed files with 17 additions and 3 deletions
|
|
@ -137,7 +137,9 @@ class Ability
|
|||
can :manage, Sponsor, conference_id: conf_ids_for_organizer
|
||||
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
|
||||
can :manage, Ticket, conference_id: conf_ids_for_organizer
|
||||
can :manage, Comment, conference_id: conf_ids_for_organizer
|
||||
can [:read, :create], Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(conference_id: conf_ids_for_organizer).pluck(:id)
|
||||
|
||||
end
|
||||
|
||||
def signed_in_with_cfp_role(user)
|
||||
|
|
@ -156,7 +158,8 @@ class Ability
|
|||
can :manage, CallForPaper, conference_id: conf_ids_for_cfp
|
||||
can :manage, Commercial, commercialable_type: 'Event',
|
||||
commercialable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id)
|
||||
can :manage, Comment, conference_id: conf_ids_for_cfp
|
||||
can [:read, :create], Comment, commentable_type: 'Event',
|
||||
commentable_id: Event.where(conference_id: conf_ids_for_cfp).pluck(:id)
|
||||
end
|
||||
|
||||
def signed_in_with_info_desk_role(user)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
%b.caret
|
||||
%ul.dropdown-menu
|
||||
= render 'layouts/user_menu'
|
||||
- if can? :manage, Comment
|
||||
- if can? :read, Comment
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "unread-comments-preview"}
|
||||
|
|
|
|||
9
spec/factories/comments.rb
Normal file
9
spec/factories/comments.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :comment do
|
||||
body 'Most interresting comment ever, created by a girl.'
|
||||
user
|
||||
association :commentable, factory: :event
|
||||
end
|
||||
end
|
||||
|
|
@ -47,6 +47,7 @@ FactoryGirl.define do
|
|||
event.difficulty_level = build(:difficulty_level, conference: event.conference)
|
||||
event.track = build(:track, conference: event.conference)
|
||||
event.room = build(:room, conference: event.conference)
|
||||
event.comment_threads << build(:comment, commentable: event)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -141,6 +141,7 @@ describe 'User' do
|
|||
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
|
||||
it{ should be_able_to(:manage, event.commercials.first) }
|
||||
it{ should_not be_able_to(:manage, other_event.commercials.first) }
|
||||
it{ should be_able_to([:read, :create], event.comment_threads.first) }
|
||||
end
|
||||
|
||||
context 'when user has the role cfp' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue