Commit a8fd5395 authored by Leandro Nunes's avatar Leandro Nunes
Browse files

fixing event plugin tests

parent 4a051199
......@@ -114,7 +114,7 @@ class Event < Article
end
def duration
((self.end_date || self.start_date) - self.start_date).to_i
(((self.end_date || self.start_date) - self.start_date).to_i/60/60/24)
end
alias_method :article_lead, :lead
......
......@@ -30,13 +30,13 @@ class EventPlugin::EventBlock < Block
events = user.nil? ? events.public : events.display_filter(user,nil)
if future_only
events = events.where('start_date >= ?', Date.today)
events = events.where('start_date >= ?', DateTime.now.beginning_of_day)
end
if date_distance_limit > 0
events = events.by_range([
Date.today - date_distance_limit,
Date.today + date_distance_limit
DateTime.now.beginning_of_day - date_distance_limit,
DateTime.now.beginning_of_day + date_distance_limit
])
end
......
require File.dirname(__FILE__) + '/../../../../test/test_helper'
# Re-raise errors caught by the controller.
class HomeController
#append_view_path File.join(File.dirname(__FILE__) + '/../../views')
append_view_path File.join(File.dirname(__FILE__) + '/../../views')
def rescue_action(e)
raise e
end
......@@ -15,7 +16,7 @@ class HomeControllerTest < ActionController::TestCase
@env.enable_plugin('EventPlugin')
@p1 = fast_create(Person, :environment_id => @env.id)
@e1a = fast_create(Event, :name=>'Event p1 A', :profile_id=>@p1.id)
@e1a = Event.create!(:name=>'Event p1 A', :profile =>@p1)
box = Box.create!(:owner => @env)
@block = EventPlugin::EventBlock.create!(:box => box)
......@@ -27,6 +28,7 @@ class HomeControllerTest < ActionController::TestCase
should 'see events microdata sturcture' do
get :index
#raise response.body.inspect
assert_select '.event-plugin_event-block ul.events'
assert_select ev
assert_select ev + 'a[itemprop="url"]'
......@@ -41,15 +43,15 @@ class HomeControllerTest < ActionController::TestCase
should 'see event duration' do
@e1a.slug = 'event1a'
@e1a.start_date = Date.today
@e1a.end_date = Date.today + 1.day
@e1a.start_date = DateTime.now
@e1a.end_date = DateTime.now + 1.day
@e1a.save!
get :index
assert_select ev + 'time.duration[itemprop="endDate"]', /1 day/
@e1a.slug = 'event1a'
@e1a.start_date = Date.today
@e1a.end_date = Date.today + 2.day
@e1a.start_date = DateTime.now
@e1a.end_date = DateTime.now + 2.day
@e1a.save!
get :index
assert_select ev + 'time.duration[itemprop="endDate"]', /2 days/
......@@ -60,8 +62,8 @@ class HomeControllerTest < ActionController::TestCase
assert_select ev + 'time.duration[itemprop="endDate"]', false
@e1a.slug = 'event1a'
@e1a.start_date = Date.today
@e1a.end_date = Date.today
@e1a.start_date = DateTime.now
@e1a.end_date = DateTime.now
@e1a.save!
get :index
assert_select ev + 'time.duration[itemprop="endDate"]', false
......
......@@ -2,7 +2,7 @@
<ul class="events">
<% block.events(user).map do |event| %>
<% days_left = ( event.start_date - Date.today ).round %>
<% days_left = ( (event.start_date - DateTime.now)/60/60/24 ).round %>
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Event" class="event">
<%= render(
:file => 'event_plugin/event_block_item',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment