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

change event start date and ende date to datetime

parent 180ad529
......@@ -92,10 +92,10 @@ class SearchController < PublicController
def events
if params[:year].blank? && params[:year].blank? && params[:day].blank?
@date = Date.today
@date = DateTime.now
else
year = (params[:year] ? params[:year].to_i : Date.today.year)
month = (params[:month] ? params[:month].to_i : Date.today.month)
year = (params[:year] ? params[:year].to_i : DateTime.now.year)
month = (params[:month] ? params[:month].to_i : DateTime.now.month)
day = (params[:day] ? params[:day].to_i : 1)
@date = build_date(year, month, day)
end
......@@ -106,9 +106,7 @@ class SearchController < PublicController
@events = @category ?
environment.events.by_day(@date).in_category(Category.find(@category_id)).paginate(:per_page => per_page, :page => params[:page]) :
environment.events.by_day(@date).paginate(:per_page => per_page, :page => params[:page])
end
if params[:year] || params[:month]
elsif params[:year] || params[:month]
@events = @category ?
environment.events.by_month(@date).in_category(Category.find(@category_id)).paginate(:per_page => per_page, :page => params[:page]) :
environment.events.by_month(@date).paginate(:per_page => per_page, :page => params[:page])
......
......@@ -43,9 +43,14 @@ module DatesHelper
end
# formats a datetime for displaying.
def show_time(time)
if time
def show_time(time, use_numbers = true, year = true, left_time = false)
if time && use_numbers
_('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.strftime("%M") }
elsif time && left_time
date_format = time_ago_in_words(time)
elsif time
date_format = year ? _('%{month_name} %{day}, %{year} %{hour}:%{minutes}') : _('%{month_name} %{day} %{hour}:%{minutes}')
date_format % { :day => time.day, :month_name => month_name(time.month), :year => time.year, :hour => time.hour, :minutes => time.strftime("%M") }
else
''
end
......@@ -53,7 +58,7 @@ module DatesHelper
def show_period(date1, date2 = nil, use_numbers = false)
if (date1 == date2) || (date2.nil?)
show_date(date1, use_numbers)
show_time(date1, use_numbers)
else
if date1.year == date2.year
if date1.month == date2.month
......@@ -106,18 +111,18 @@ module DatesHelper
def build_date(year, month, day = 1)
if year.blank? and month.blank? and day.blank?
Date.today
DateTime.now
else
if year.blank?
year = Date.today.year
year = DateTime.now.year
end
if month.blank?
month = Date.today.month
month = DateTime.now.month
end
if day.blank?
day = 1
end
Date.new(year.to_i, month.to_i, day.to_i)
DateTime.new(year.to_i, month.to_i, day.to_i)
end
end
......
......@@ -16,7 +16,7 @@ module EventsHelper
content_tag( 'tr',
content_tag('td',
content_tag('div', show_date(article.start_date) + ( article.end_date.nil? ? '' : (_(" to ") + show_date(article.end_date))),:class => 'event-date' ) +
content_tag('div', show_time(article.start_date) + ( article.end_date.nil? ? '' : (_(" to ") + show_time(article.end_date))),:class => 'event-date' ) +
content_tag('div',link_to(article.name,article.url),:class => 'event-title') +
content_tag('div',(article.address.nil? or article.address == '') ? '' : (_('Place: ') + article.address),:class => 'event-place')
)
......
......@@ -23,7 +23,7 @@ class Event < Article
def initialize(*args)
super(*args)
self.start_date ||= Date.today
self.start_date ||= DateTime.now
end
validates_presence_of :title, :start_date
......@@ -35,7 +35,7 @@ class Event < Article
end
scope :by_day, lambda { |date|
{ :conditions => ['start_date = :date AND end_date IS NULL OR (start_date <= :date AND end_date >= :date)', {:date => date}],
{ :conditions => [' start_date >= :start_date AND start_date <= :end_date AND end_date IS NULL OR (start_date <= :end_date AND end_date >= :start_date)', {:start_date => date.beginning_of_day, :end_date => date.end_of_day}],
:order => 'start_date ASC'
}
}
......@@ -80,7 +80,7 @@ class Event < Article
def self.date_range(year, month)
if year.nil? || month.nil?
today = Date.today
today = DateTime.now
year = today.year
month = today.month
else
......@@ -88,7 +88,7 @@ class Event < Article
month = month.to_i
end
first_day = Date.new(year, month, 1)
first_day = DateTime.new(year, month, 1)
last_day = first_day + 1.month - 1.day
first_day..last_day
......
......@@ -8,9 +8,9 @@
<%= render :partial => 'general_fields' %>
<%= render :partial => 'translatable' %>
<%= labelled_form_field(_('Start date'), pick_date(:article, :start_date)) %>
<%= labelled_form_field(_('Start date'), date_field('article[start_date]', @article.start_date,_('%Y-%m-%d'), {:time => true}, {:id => 'article_start_date'} )) %>
<%= labelled_form_field(_('End date'), pick_date(:article, :end_date)) %>
<%= labelled_form_field(_('End date'), date_field('article[end_date]', @article.end_date, _('%Y-%m-%d'), {:time => true}, {:id => 'article_end_date'})) %>
<%= labelled_form_field(_('Event website:'), text_field(:article, :link)) %>
......
class ChangeArticleDateToDatetime < ActiveRecord::Migration
def up
change_table :articles do |t|
t.change :start_date, :datetime
t.change :end_date, :datetime
end
change_table :article_versions do |t|
t.change :start_date, :datetime
t.change :end_date, :datetime
end
end
def down
change_table :articles do |t|
t.change :start_date, :date
t.change :end_date, :date
end
change_table :article_versions do |t|
t.change :start_date, :date
t.change :end_date, :date
end
end
end
......@@ -1505,7 +1505,8 @@ table#recaptcha_table tr:hover td {
.event-date {
background: url('/images/calendar_date_select/calendar-icon.png') no-repeat left center;
padding: 5px;
padding: 2px;
padding-left: 15px;
}
.event-link {
......
......@@ -8,12 +8,12 @@ class EventsControllerTest < ActionController::TestCase
attr_reader :profile
should 'list today events by default' do
profile.events << Event.new(:name => 'Joao Birthday', :start_date => Date.today)
profile.events << Event.new(:name => 'Maria Birthday', :start_date => Date.today)
profile.events << Event.new(:name => 'Joao Birthday', :start_date => DateTime.now)
profile.events << Event.new(:name => 'Maria Birthday', :start_date => DateTime.now)
get :events, :profile => profile.identifier
today = Date.today.strftime("%B %d, %Y")
today = DateTime.now.strftime("%B %d, %Y")
assert_tag :tag => 'div', :attributes => {:id => "agenda-items"},
:descendant => {:tag => 'h3', :content => "Events for #{today}"},
:descendant => {:tag => 'tr', :content => "Joao Birthday"},
......@@ -23,15 +23,15 @@ class EventsControllerTest < ActionController::TestCase
should 'display calendar of current month' do
get :events, :profile => profile.identifier
month = Date.today.strftime("%B %Y")
month = DateTime.now.strftime("%B %Y")
assert_tag :tag => 'table', :attributes => {:class => /current-month/}, :descendant => {:tag => 'caption', :content => /#{month}/}
end
should 'display links to previous and next month' do
get :events, :profile => profile.identifier
prev_month = Date.today - 1.month
next_month = Date.today + 1.month
prev_month = DateTime.now - 1.month
next_month = DateTime.now + 1.month
prev_month_name = prev_month.strftime("%B")
next_month_name = next_month.strftime("%B")
assert_tag :tag =>'a', :attributes => {:href => "/profile/#{profile.identifier}/events/#{prev_month.year}/#{prev_month.month}"}, :content => prev_month_name
......@@ -40,14 +40,14 @@ class EventsControllerTest < ActionController::TestCase
should 'see the events paginated' do
30.times do |i|
profile.events << Event.new(:name => "Lesson #{i}", :start_date => Date.today)
profile.events << Event.new(:name => "Lesson #{i}", :start_date => DateTime.now)
end
get :events, :profile => profile.identifier
assert_equal 20, assigns(:events).size
end
should 'show events of specific day' do
profile.events << Event.new(:name => 'Joao Birthday', :start_date => Date.new(2009, 10, 28))
profile.events << Event.new(:name => 'Joao Birthday', :start_date => DateTime.new(2009, 10, 28))
get :events_by_day, :profile => profile.identifier, :year => 2009, :month => 10, :day => 28
......
......@@ -305,7 +305,7 @@ class SearchControllerTest < ActionController::TestCase
should 'search for events' do
person = create_user('teste').person
event = create_event(person, :name => 'an event to be found', :start_date => Date.today)
event = create_event(person, :name => 'an event to be found', :start_date => DateTime.now)
get :events, :query => 'event to be found'
......@@ -314,10 +314,10 @@ class SearchControllerTest < ActionController::TestCase
should 'return events of the day' do
person = create_user('someone').person
ten_days_ago = Date.today - 10.day
ten_days_ago = DateTime.now - 10.day
ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago)
ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month)
ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => DateTime.now - 2.month)
get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year
assert_equal [ev1], assigns(:events)
......@@ -325,9 +325,11 @@ class SearchControllerTest < ActionController::TestCase
should 'return events of the day with category' do
person = create_user('someone').person
ten_days_ago = Date.today - 10.day
ten_days_ago = DateTime.now - 10.day
ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => ten_days_ago)
ev1 = create_event(person, :name => 'event 1', :start_date => ten_days_ago)
ev1.categories = [@category]
ev2 = create_event(person, :name => 'event 2', :start_date => ten_days_ago)
get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/')
......@@ -337,8 +339,8 @@ class SearchControllerTest < ActionController::TestCase
should 'return events of today when no date specified' do
person = create_user('someone').person
ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => Date.today)
ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month)
ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id], :start_date => DateTime.now)
ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => DateTime.now - 2.month)
get :events
......@@ -349,9 +351,9 @@ class SearchControllerTest < ActionController::TestCase
person = create_user('someone').person
ev1 = create_event(person, :name => 'event 1', :category_ids => [@category.id],
:start_date => Date.today + 2.month)
:start_date => DateTime.now + 2.month)
ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id],
:start_date => Date.today + 2.day)
:start_date => DateTime.now + 2.day)
get :events
......@@ -362,8 +364,8 @@ class SearchControllerTest < ActionController::TestCase
should 'list events for a given month' do
person = create_user('testuser').person
create_event(person, :name => 'upcoming event 1', :category_ids => [@category.id], :start_date => Date.new(2008, 1, 25))
create_event(person, :name => 'upcoming event 2', :category_ids => [@category.id], :start_date => Date.new(2008, 4, 27))
create_event(person, :name => 'upcoming event 1', :category_ids => [@category.id], :start_date => DateTime.new(2008, 1, 25))
create_event(person, :name => 'upcoming event 2', :category_ids => [@category.id], :start_date => DateTime.new(2008, 4, 27))
get :events, :year => '2008', :month => '1'
......@@ -373,7 +375,7 @@ class SearchControllerTest < ActionController::TestCase
should 'see the events paginated' do
person = create_user('testuser').person
30.times do |i|
create_event(person, :name => "Event #{i}", :start_date => Date.today)
create_event(person, :name => "Event #{i}", :start_date => DateTime.now)
end
get :events
assert_equal 20, assigns(:events).size
......@@ -416,7 +418,7 @@ class SearchControllerTest < ActionController::TestCase
end
should 'display current year/month by default as caption of current month' do
Date.expects(:today).returns(Date.new(2008, 8, 1)).at_least_once
DateTime.expects(:now).returns(DateTime.new(2008, 8, 1)).at_least_once
get :events
assert_tag :tag => 'table', :attributes => {:class => /current-month/}, :descendant => {:tag => 'caption', :content => /August 2008/}
......@@ -475,7 +477,7 @@ class SearchControllerTest < ActionController::TestCase
should 'show events of specific day' do
person = create_user('anotheruser').person
event = create_event(person, :name => 'Joao Birthday', :start_date => Date.new(2009, 10, 28))
event = create_event(person, :name => 'Joao Birthday', :start_date => DateTime.new(2009, 10, 28))
get :events_by_day, :year => 2009, :month => 10, :day => 28
......@@ -484,8 +486,8 @@ class SearchControllerTest < ActionController::TestCase
should 'ignore filter of events if category not exists' do
person = create_user('anotheruser').person
create_event(person, :name => 'Joao Birthday', :start_date => Date.new(2009, 10, 28), :category_ids => [@category.id])
create_event(person, :name => 'Maria Birthday', :start_date => Date.new(2009, 10, 28))
create_event(person, :name => 'Joao Birthday', :start_date => DateTime.new(2009, 10, 28), :category_ids => [@category.id])
create_event(person, :name => 'Maria Birthday', :start_date => DateTime.new(2009, 10, 28))
id_of_unexistent_category = Category.last.id + 10
......@@ -772,7 +774,7 @@ class SearchControllerTest < ActionController::TestCase
protected
def create_event(profile, options)
ev = build(Event, { :name => 'some event', :start_date => Date.new(2008,1,1) }.merge(options))
ev = build(Event, { :name => 'some event', :start_date => DateTime.new(2008,1,1) }.merge(options))
ev.profile = profile
ev.save!
ev
......
......@@ -84,7 +84,7 @@ class DatesHelperTest < ActiveSupport::TestCase
end
should 'fallback to current year/month in show_month' do
Date.expects(:today).returns(Date.new(2008,11,1)).at_least_once
DateTime.expects(:now).returns(DateTime.new(2008,11,1)).at_least_once
assert_equal 'November 2008', show_month(nil, nil)
assert_equal 'November 2008', show_month('', '')
end
......
......@@ -29,15 +29,9 @@ class EventTest < ActiveSupport::TestCase
assert_equal 'South Noosfero street, 88', e.address
end
should 'have a start date' do
e = Event.new
e.start_date = Date.today
assert_kind_of Date, e.start_date
end
should 'set start date default value as today' do
e = Event.new
assert_equal Date.today, e.start_date
assert_in_delta DateTime.now.to_i, e.start_date.to_i, 1
end
should 'require start date' do
......@@ -45,38 +39,32 @@ class EventTest < ActiveSupport::TestCase
e.start_date = nil
e.valid?
assert e.errors[:start_date.to_s].present?
e.start_date = Date.today
e.start_date = DateTime.now
e.valid?
refute e.errors[:start_date.to_s].present?
end
should 'have a end date' do
e = Event.new
e.end_date = Date.today
assert_kind_of Date, e.end_date
end
should 'use its own icon' do
assert_equal 'event', Event.icon_name
end
should 'not allow end date before start date' do
e = build(Event, :start_date => Date.new(2008, 01, 01), :end_date => Date.new(2007,01,01))
e = build(Event, :start_date => DateTime.new(2008, 01, 01), :end_date => DateTime.new(2007,01,01))
e.valid?
assert e.errors[:start_date.to_s].present?
e.end_date = Date.new(2008,01,05)
e.end_date = DateTime.new(2008,01,05)
e.valid?
refute e.errors[:start_date.to_s].present?
end
should 'find by range of dates' do
profile = create_user('testuser').person
e1 = create(Event, :name => 'e1', :start_date => Date.new(2008,1,1), :profile => profile)
e2 = create(Event, :name => 'e2', :start_date => Date.new(2008,2,1), :profile => profile)
e3 = create(Event, :name => 'e3', :start_date => Date.new(2008,3,1), :profile => profile)
e1 = create(Event, :name => 'e1', :start_date => DateTime.new(2008,1,1), :profile => profile)
e2 = create(Event, :name => 'e2', :start_date => DateTime.new(2008,2,1), :profile => profile)
e3 = create(Event, :name => 'e3', :start_date => DateTime.new(2008,3,1), :profile => profile)
found = Event.by_range(Date.new(2008, 1, 1)..Date.new(2008, 2, 28))
found = Event.by_range(DateTime.new(2008, 1, 1)..DateTime.new(2008, 2, 28))
assert_includes found, e1
assert_includes found, e2
assert_not_includes found, e3
......@@ -84,32 +72,32 @@ class EventTest < ActiveSupport::TestCase
should 'filter events by range' do
profile = create_user('testuser').person
e1 = create(Event, :name => 'e1', :start_date => Date.new(2008,1,15), :profile => profile)
assert_includes profile.events.by_range(Date.new(2008, 1, 10)..Date.new(2008, 1, 20)), e1
e1 = create(Event, :name => 'e1', :start_date => DateTime.new(2008,1,15), :profile => profile)
assert_includes profile.events.by_range(DateTime.new(2008, 1, 10)..DateTime.new(2008, 1, 20)), e1
end
should 'provide period for searching in month' do
assert_equal Date.new(2008, 1, 1)..Date.new(2008,1,31), Event.date_range(2008, 1)
assert_equal Date.new(2008, 2, 1)..Date.new(2008,2,29), Event.date_range(2008, 2)
assert_equal Date.new(2007, 2, 1)..Date.new(2007,2,28), Event.date_range(2007, 2)
assert_equal DateTime.new(2008, 1, 1)..DateTime.new(2008,1,31), Event.date_range(2008, 1)
assert_equal DateTime.new(2008, 2, 1)..DateTime.new(2008,2,29), Event.date_range(2008, 2)
assert_equal DateTime.new(2007, 2, 1)..DateTime.new(2007,2,28), Event.date_range(2007, 2)
end
should 'support string arguments to Event#date_range' do
assert_equal Date.new(2008,1,1)..Date.new(2008,1,31), Event.date_range('2008', '1')
assert_equal DateTime.new(2008,1,1)..DateTime.new(2008,1,31), Event.date_range('2008', '1')
end
should 'provide range of dates for event with both dates filled' do
e = build(Event, :start_date => Date.new(2008, 1, 1), :end_date => Date.new(2008, 1, 5))
assert_equal (Date.new(2008,1,1)..Date.new(2008,1,5)), e.date_range
e = build(Event, :start_date => DateTime.new(2008, 1, 1), :end_date => DateTime.new(2008, 1, 5))
assert_equal (DateTime.new(2008,1,1)..DateTime.new(2008,1,5)), e.date_range
end
should 'provide range of dates for event with only start date' do
e = build(Event, :start_date => Date.new(2008, 1, 1))
assert_equal (Date.new(2008,1,1)..Date.new(2008,1,1)), e.date_range
e = build(Event, :start_date => DateTime.new(2008, 1, 1))
assert_equal (DateTime.new(2008,1,1)..DateTime.new(2008,1,1)), e.date_range
end
should 'provide nice display format' do
event = build(Event, :start_date => Date.new(2008,1,1), :end_date => Date.new(2008,1,1), :link => 'http://www.myevent.org', :body => '<p>my somewhat short description</p>')
event = build(Event, :start_date => DateTime.new(2008,1,1), :end_date => DateTime.new(2008,1,1), :link => 'http://www.myevent.org', :body => '<p>my somewhat short description</p>')
display = instance_eval(&event.to_html)
assert_tag_in_string display, :content => Regexp.new("January 1, 2008")
......@@ -148,7 +136,7 @@ class EventTest < ActiveSupport::TestCase
profile = create_user('testuser').person
event = create(Event, :profile => profile, :name => 'test',
:body => '<p>first paragraph </p><p>second paragraph </p>',
:link => 'www.colivre.coop.br', :start_date => Date.today)
:link => 'www.colivre.coop.br', :start_date => DateTime.now)
assert_match '<p>first paragraph </p>', event.first_paragraph
end
......@@ -161,7 +149,7 @@ class EventTest < ActiveSupport::TestCase
should 'filter HTML in body' do
profile = create_user('testuser').person
e = create(Event, :profile => profile, :name => 'test', :body => '<p>a paragraph (valid)</p><script type="text/javascript">/* this is invalid */</script>"', :link => 'www.colivre.coop.br', :start_date => Date.today)
e = create(Event, :profile => profile, :name => 'test', :body => '<p>a paragraph (valid)</p><script type="text/javascript">/* this is invalid */</script>"', :link => 'www.colivre.coop.br', :start_date => DateTime.now)
assert_tag_in_string e.body, :tag => 'p', :content => 'a paragraph (valid)'
assert_no_tag_in_string e.body, :tag => 'script'
......@@ -169,7 +157,7 @@ class EventTest < ActiveSupport::TestCase
should 'filter HTML in name' do
profile = create_user('testuser').person
e = create(Event, :profile => profile, :name => '<p>a paragraph (valid)</p><script type="text/javascript">/* this is invalid */</script>"', :link => 'www.colivre.coop.br', :start_date => Date.today)
e = create(Event, :profile => profile, :name => '<p>a paragraph (valid)</p><script type="text/javascript">/* this is invalid */</script>"', :link => 'www.colivre.coop.br', :start_date => DateTime.now)
assert_tag_in_string e.name, :tag => 'p', :content => 'a paragraph (valid)'
assert_no_tag_in_string e.name, :tag => 'script'
......@@ -184,8 +172,8 @@ class EventTest < ActiveSupport::TestCase
should 'list all events' do
profile = fast_create(Profile)
event1 = build(Event, :name => 'Ze Birthday', :start_date => Date.today)
event2 = build(Event, :name => 'Mane Birthday', :start_date => Date.today >> 1)
event1 = build(Event, :name => 'Ze Birthday', :start_date => DateTime.now)
event2 = build(Event, :name => 'Mane Birthday', :start_date => DateTime.now >> 1)
profile.events << [event1, event2]
assert_includes profile.events, event1
assert_includes profile.events, event2
......@@ -194,7 +182,7 @@ class EventTest < ActiveSupport::TestCase
should 'list events by day' do
profile = fast_create(Profile)
today = Date.today
today = DateTime.now
yesterday_event = build(Event, :name => 'Joao Birthday', :start_date => today - 1.day)
today_event = build(Event, :name => 'Ze Birthday', :start_date => today)
tomorrow_event = build(Event, :name => 'Mane Birthday', :start_date => today + 1.day)
......@@ -207,7 +195,7 @@ class EventTest < ActiveSupport::TestCase
should 'list events by month' do
profile = fast_create(Profile)
today = Date.new(2013, 10, 6)
today = DateTime.new(2013, 10, 6)
last_month_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.month)
......@@ -230,7 +218,7 @@ class EventTest < ActiveSupport::TestCase
should 'event by month ordered by start date'do
profile = fast_create(Profile)
today = Date.new(2013, 10, 6)
today = DateTime.new(2013, 10, 6)
event_1 = Event.new(:name => 'Maria Birthday', :start_date => today + 1.day)
event_2 = Event.new(:name => 'Joana Birthday', :start_date => today - 1.day)
......@@ -248,7 +236,7 @@ class EventTest < ActiveSupport::TestCase
should 'list events in a range' do
profile = fast_create(Profile)
today = Date.today
today = DateTime.now
event_in_range = build(Event, :name => 'Noosfero Conference', :start_date => today - 2.day, :end_date => today + 2.day)
event_in_day = build(Event, :name => 'Ze Birthday', :start_date => today)
......@@ -262,7 +250,7 @@ class EventTest < ActiveSupport::TestCase
should 'not list events out of range' do
profile = fast_create(Profile)
today = Date.today
today = DateTime.now
event_in_range1 = build(Event, :name => 'Foswiki Conference', :start_date => today - 2.day, :end_date => today + 2.day)
event_in_range2 = build(Event, :name => 'Debian Conference', :start_date => today - 2.day, :end_date => today + 3.day)
event_out_of_range = build(Event, :name => 'Ze Birthday', :start_date => today - 5.day, :end_date => today - 3.day)
......
......@@ -1573,7 +1573,7 @@ class ProfileTest < ActiveSupport::TestCase
should 'list events by day' do
profile = fast_create(Profile)
today = Date.today
today = DateTime.now
yesterday_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.day)
today_event = Event.new(:name => 'Ze Birthday', :start_date => today)
tomorrow_event = Event.new(:name => 'Mane Birthday', :start_date => today + 1.day)
......@@ -1599,7 +1599,7 @@ class ProfileTest < ActiveSupport::TestCase
should 'list events in a range' do
profile = fast_create(Profile)
today = Date.today
today = DateTime.now
event_in_range = Event.new(:name => 'Noosfero Conference', :start_date => today - 2.day, :end_date => today + 2.day)
event_in_day = Event.new(:name => 'Ze Birthday', :start_date => today)
......
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