From b041998d66aaf2a2542a4aee5420dcf9cd95e7cb Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 23 Sep 2010 12:44:56 -0300 Subject: [PATCH] Events are displayed only if the user is allowed to see it --- app/helpers/events_helper.rb | 4 ++-- features/events.feature | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 98f9e64..9a656ab 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -6,7 +6,7 @@ module EventsHelper content_tag('h2', title) + content_tag('div', (events.any? ? - content_tag('table', events.select { |item| item.public? }.map {|item| display_event_in_listing(item)}.join('')) : + content_tag('table', events.select { |item| item.display_to?(user) }.map {|item| display_event_in_listing(item)}.join('')) : content_tag('em', _('No events for this date'), :class => 'no-events') ), :id => 'agenda-items' ) @@ -26,7 +26,7 @@ module EventsHelper # the day itself date, # is there any events in this date? - events.any? do |event| + events.select {|event| event.display_to?(user)}.any? do |event| event.date_range.include?(date) end, # is this date in the current month? diff --git a/features/events.feature b/features/events.feature index 3ce98f4..cc3636c 100644 --- a/features/events.feature +++ b/features/events.feature @@ -185,3 +185,20 @@ Feature: events And I press "Spread this" And I am on /profile/sample-community/events/2009/10/24 Then I should see "Another Conference" + + Scenario: events that are not allowed to the user should not be displayed nor listed in the calendar + Given the following events + | owner | name | start_date | published | + | josesilva | Unpublished event | 2009-10-25 | false | + When I am on /profile/josesilva/events/2009/10/25 + Then I should not see "Unpublished event" + And I should not see "25" link + + Scenario: events that are allowed to the user should be displayed and listed in the calendar + Given the following events + | owner | name | start_date | published | + | josesilva | Unpublished event | 2009-10-25 | false | + And I am logged in as "josesilva" + When I am on /profile/josesilva/events/2009/10/25 + Then I should see "Unpublished event" + And I should see "25" link -- libgit2 0.21.2