[Git][noosfero/noosfero][master] 13 commits: change event start date and ende date to datetime

Leandro Nunes gitlab at gitlab.com
Thu Aug 13 15:05:08 BRT 2015


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
08bbc6ff by Leandro Nunes dos Santos at 2015-07-24T13:09:25Z
change event start date and ende date to datetime

- - - - -
e881f6c1 by Leandro Nunes dos Santos at 2015-07-24T18:27:24Z
Adapting views and helpers to datime format

- - - - -
5949b012 by Leandro Nunes dos Santos at 2015-07-24T18:29:03Z
Merge branch 'master' into article_datetime

- - - - -
4cdda51f by Victor Costa at 2015-07-29T10:00:34Z
Fix event test when a time zone is set

- - - - -
d168d5b8 by Leandro Nunes dos Santos at 2015-08-12T09:05:20Z
Merge branch 'master' into article_datetime

- - - - -
e021f701 by Leandro Nunes dos Santos at 2015-08-13T00:20:07Z
change event start date and ende date to datetime

- - - - -
dc6c5813 by Leandro Nunes dos Santos at 2015-08-13T00:20:07Z
Adapting views and helpers to datime format

- - - - -
f759d50d by Victor Costa at 2015-08-13T00:20:07Z
Fix event test when a time zone is set

- - - - -
4a051199 by Leandro Nunes dos Santos at 2015-08-13T00:20:07Z
adapting tests for datetime values

- - - - -
a8fd5395 by Leandro Nunes dos Santos at 2015-08-13T01:29:25Z
fixing event plugin tests

- - - - -
648f0e6b by Leandro Nunes dos Santos at 2015-08-13T10:20:44Z
Merge branch 'article_datetime' of gitlab.com:participa/noosfero into article_datetime

- - - - -
e7f5b1b3 by Leandro Nunes dos Santos at 2015-08-13T14:40:15Z
adapting community track plugin for datetime values

- - - - -
fdf74522 by Leandro Nunes at 2015-08-13T18:04:59Z
Merge branch 'article_datetime' into 'master'

Put start and end dates as datetime for articles

change the start_date and end_date from date to datetime

See merge request !634

- - - - -


22 changed files:

- app/controllers/public/search_controller.rb
- app/helpers/content_viewer_helper.rb
- app/helpers/dates_helper.rb
- app/helpers/events_helper.rb
- app/helpers/forms_helper.rb
- app/models/event.rb
- app/views/cms/_event.html.erb
- app/views/content_viewer/_publishing_info.html.erb
- + db/migrate/20150722042714_change_article_date_to_datetime.rb
- plugins/community_track/lib/community_track_plugin/step.rb
- plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
- plugins/community_track/test/unit/community_track_plugin/step_test.rb
- plugins/event/lib/event_plugin/event_block.rb
- plugins/event/test/functional/event_block_test.rb
- plugins/event/views/blocks/event.html.erb
- public/designs/themes/base/style.scss
- test/functional/events_controller_test.rb
- test/functional/search_controller_test.rb
- test/unit/content_viewer_helper_test.rb
- test/unit/dates_helper_test.rb
- test/unit/event_test.rb
- test/unit/profile_test.rb


Changes:

=====================================
app/controllers/public/search_controller.rb
=====================================
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -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])


=====================================
app/helpers/content_viewer_helper.rb
=====================================
--- a/app/helpers/content_viewer_helper.rb
+++ b/app/helpers/content_viewer_helper.rb
@@ -51,7 +51,7 @@ module ContentViewerHelper
     elsif date_format == 'past_time'
       left_time = true
     end
-    content_tag('span', show_date(article.published_at, use_numbers , year, left_time), :class => 'date')
+    content_tag('span', show_time(article.published_at, use_numbers , year, left_time), :class => 'date')
   end
 
   def link_to_comments(article, args = {})


=====================================
app/helpers/dates_helper.rb
=====================================
--- a/app/helpers/dates_helper.rb
+++ b/app/helpers/dates_helper.rb
@@ -43,9 +43,14 @@ module DatesHelper
   end
 
   # formats a datetime for displaying.
-  def show_time(time)
-    if time
-      _('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.strftime("%M") }
+  def show_time(time, use_numbers = false, year = true, left_time = false)
+    if time && use_numbers
+      _('%{month}/%{day}/%{year}, %{hour}:%{minutes}') % { :year => (year ? time.year : ''), :month => 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
@@ -72,8 +77,8 @@ module DatesHelper
         end
       else
         _('from %{date1} to %{date2}') % {
-          :date1 => show_date(date1, use_numbers),
-          :date2 => show_date(date2, use_numbers)
+          :date1 => show_time(date1, use_numbers),
+          :date2 => show_time(date2, use_numbers)
         }
       end
     end
@@ -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
 


=====================================
app/helpers/events_helper.rb
=====================================
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -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')
       )


=====================================
app/helpers/forms_helper.rb
=====================================
--- a/app/helpers/forms_helper.rb
+++ b/app/helpers/forms_helper.rb
@@ -151,7 +151,7 @@ module FormsHelper
     datepicker_options[:close_text] ||= _('Done')
     datepicker_options[:constrain_input] ||= true
     datepicker_options[:current_text] ||= _('Today')
-    datepicker_options[:date_format] ||= 'mm/dd/yy'
+    datepicker_options[:date_format] ||= 'yy/mm/dd'
     datepicker_options[:day_names] ||= [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
     datepicker_options[:day_names_min] ||= [_('Su'), _('Mo'), _('Tu'), _('We'), _('Th'), _('Fr'), _('Sa')]
     datepicker_options[:day_names_short] ||= [_('Sun'), _('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat')]
@@ -236,7 +236,7 @@ module FormsHelper
         weekHeader: #{datepicker_options[:week_header].to_json},
         yearRange: #{datepicker_options[:year_range].to_json},
         yearSuffix: #{datepicker_options[:year_suffix].to_json}
-      })
+      }).datepicker('setDate', new Date('#{value}'))
     </script>
     ".html_safe
     result


=====================================
app/models/event.rb
=====================================
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -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
@@ -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


=====================================
app/views/cms/_event.html.erb
=====================================
--- a/app/views/cms/_event.html.erb
+++ b/app/views/cms/_event.html.erb
@@ -8,9 +8,8 @@
 <%= render :partial => 'general_fields' %>
 <%= render :partial => 'translatable' %>
 
-<%= labelled_form_field(_('Start date'), pick_date(:article, :start_date)) %>
+<%= date_range_field('article[start_date]', 'article[end_date]', @article.start_date, @article.end_date, _('%Y-%m-%d %H:%M'), {:time => true}, {:id => 'article_start_date'} ) %>
 
-<%= labelled_form_field(_('End date'), pick_date(:article, :end_date)) %>
 
 <%= labelled_form_field(_('Event website:'), text_field(:article, :link)) %>
 


=====================================
app/views/content_viewer/_publishing_info.html.erb
=====================================
--- a/app/views/content_viewer/_publishing_info.html.erb
+++ b/app/views/content_viewer/_publishing_info.html.erb
@@ -1,6 +1,6 @@
 <span class="publishing-info">
   <span class="date">
-    <%= show_date(@page.published_at) %>
+    <%= show_time(@page.published_at) %>
   </span>
   <span class="author">
     <%= _(", by %s") % (@page.author ? link_to(@page.author_name, @page.author_url) : @page.author_name) %>


=====================================
db/migrate/20150722042714_change_article_date_to_datetime.rb
=====================================
--- /dev/null
+++ b/db/migrate/20150722042714_change_article_date_to_datetime.rb
@@ -0,0 +1,27 @@
+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


=====================================
plugins/community_track/lib/community_track_plugin/step.rb
=====================================
--- a/plugins/community_track/lib/community_track_plugin/step.rb
+++ b/plugins/community_track/lib/community_track_plugin/step.rb
@@ -29,8 +29,8 @@ class CommunityTrackPlugin::Step < Folder
 
   def initialize(*args)
     super(*args)
-    self.start_date ||= Date.today
-    self.end_date ||= Date.today + 1.day
+    self.start_date ||= DateTime.now
+    self.end_date ||= DateTime.now + 1.day
   end
   
   def set_hidden_position
@@ -72,20 +72,20 @@ class CommunityTrackPlugin::Step < Folder
   end
 
   def active?
-    (start_date..end_date).include?(Date.today)
+    (start_date..end_date).cover?(DateTime.now)
   end
 
   def finished?
-    Date.today > end_date
+    DateTime.now > end_date
   end
 
   def waiting?
-    Date.today < start_date
+    DateTime.now < start_date
   end
 
   def schedule_activation
     return if !changes['start_date'] && !changes['end_date']
-    if Date.today <= end_date || accept_comments
+    if DateTime.now <= end_date || accept_comments
       schedule_date = !accept_comments ? start_date : end_date + 1.day
       CommunityTrackPlugin::ActivationJob.find(id).destroy_all
       Delayed::Job.enqueue(CommunityTrackPlugin::ActivationJob.new(self.id), :run_at => schedule_date)


=====================================
plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
=====================================
--- a/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
+++ b/plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
@@ -6,7 +6,7 @@ class ContentViewerControllerTest < ActionController::TestCase
   def setup
     @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community')
     @track = create_track('track', @profile)
-    @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today, :tool_type => TinyMceArticle.name)
+    @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day, :tool_type => TinyMceArticle.name)
 
     user = create_user('testinguser')
     login_as(user.login)


=====================================
plugins/community_track/test/unit/community_track_plugin/step_test.rb
=====================================
--- a/plugins/community_track/test/unit/community_track_plugin/step_test.rb
+++ b/plugins/community_track/test/unit/community_track_plugin/step_test.rb
@@ -9,7 +9,7 @@ class StepTest < ActiveSupport::TestCase
     @track.add_category(@category)
     @track.save!
 
-    @step = CommunityTrackPlugin::Step.new(:name => 'Step', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today)
+    @step = CommunityTrackPlugin::Step.new(:name => 'Step', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day - 1.day)
     Delayed::Job.destroy_all
   end
 
@@ -22,39 +22,39 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'set accept_comments to false on create' do
-    today = Date.today
+    today = DateTime.now
     step = CommunityTrackPlugin::Step.create(:name => 'Step', :body => 'body', :profile => @profile, :parent => @track, :start_date => today, :end_date => today, :published => true)
     refute step.accept_comments
   end
 
   should 'do not allow step creation with a parent that is not a track' do
-    today = Date.today
+    today = DateTime.now
     blog = fast_create(Blog)
     step = CommunityTrackPlugin::Step.new(:name => 'Step', :body => 'body', :profile => @profile, :parent => blog, :start_date => today, :end_date => today, :published => true)
     refute step.save
   end
 
   should 'do not allow step creation without a parent' do
-    today = Date.today
+    today = DateTime.now
     step = CommunityTrackPlugin::Step.new(:name => 'Step', :body => 'body', :profile => @profile, :parent => nil, :start_date => today, :end_date => today, :published => true)
     refute step.save
   end
 
   should 'create step if end date is equal to start date' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now
     assert @step.save
   end
 
   should 'create step if end date is after start date' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today + 1.day
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now + 1.day
     assert @step.save
   end
 
   should 'do not create step if end date is before start date' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today - 1.day
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now - 1.day
     refute @step.save
   end
 
@@ -71,20 +71,20 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'be active if today is between start and end dates' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today + 1.day
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now + 1.day
     assert @step.active?
   end
 
   should 'be finished if today is after the end date' do
-    @step.start_date = Date.today - 2.day
-    @step.end_date = Date.today - 1.day
+    @step.start_date = DateTime.now - 2.day
+    @step.end_date = DateTime.now - 1.day
     assert @step.finished?
   end
 
   should 'be waiting if today is before the end date' do
-    @step.start_date = Date.today + 1.day
-    @step.end_date = Date.today + 2.day
+    @step.start_date = DateTime.now + 1.day
+    @step.end_date = DateTime.now + 2.day
     assert @step.waiting?
   end
 
@@ -95,17 +95,17 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'create delayed job' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now.beginning_of_day
+    @step.end_date = DateTime.now.end_of_day
     @step.accept_comments = false
     @step.schedule_activation
     assert_equal 1, Delayed::Job.count
-    assert_equal @step.start_date, Delayed::Job.first.run_at.to_date
+    assert_equal @step.start_date, Delayed::Job.first.run_at
   end
 
   should 'do not duplicate delayed job' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now
     @step.schedule_activation
     assert_equal 1, Delayed::Job.count
     @step.schedule_activation
@@ -113,30 +113,30 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'create delayed job when a step is saved' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now.beginning_of_day
+    @step.end_date = DateTime.now.end_of_day
     @step.save!
-    assert_equal @step.start_date, Delayed::Job.first.run_at.to_date
+    assert_equal @step.start_date, Delayed::Job.first.run_at
   end
 
   should 'create delayed job even if start date has passed' do
-    @step.start_date = Date.today - 2.days
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now - 2.days
+    @step.end_date = DateTime.now.end_of_day
     @step.accept_comments = false
     @step.schedule_activation
-    assert_equal @step.start_date, Delayed::Job.first.run_at.to_date
+    assert_equal @step.start_date, Delayed::Job.first.run_at
   end
 
   should 'create delayed job if end date has passed' do
-    @step.start_date = Date.today - 5.days
-    @step.end_date = Date.today - 2.days
+    @step.start_date = DateTime.now - 5.days
+    @step.end_date = DateTime.now - 2.days
     @step.schedule_activation
-    assert_equal @step.end_date + 1.day, Delayed::Job.first.run_at.to_date
+    assert_equal @step.end_date + 1.day, Delayed::Job.first.run_at
   end
 
   should 'do not schedule delayed job if save but do not modify date fields' do
-    @step.start_date = Date.today
-    @step.end_date = Date.today
+    @step.start_date = DateTime.now
+    @step.end_date = DateTime.now.end_of_day
     @step.save!
     assert_equal 1, Delayed::Job.count
     Delayed::Job.destroy_all
@@ -149,13 +149,13 @@ class StepTest < ActiveSupport::TestCase
     refute @step.position
     @step.save!
     assert_equal 1, @step.position
-    step2 = CommunityTrackPlugin::Step.new(:name => 'Step2', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today)
+    step2 = CommunityTrackPlugin::Step.new(:name => 'Step2', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day)
     step2.save!
     assert_equal 2, step2.position
   end
 
   should 'accept comments if step is active' do
-    @step.start_date = Date.today
+    @step.start_date = DateTime.now
     @step.save!
     refute @step.accept_comments
     @step.toggle_activation
@@ -164,8 +164,8 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'do not accept comments if step is not active' do
-    @step.start_date = Date.today + 2.days
-    @step.end_date = Date.today + 3.days
+    @step.start_date = DateTime.now + 2.days
+    @step.end_date = DateTime.now + 3.days
     @step.save!
     refute @step.published
     @step.toggle_activation
@@ -174,14 +174,14 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'do not accept comments if step is not active anymore' do
-    @step.start_date = Date.today
+    @step.end_date = DateTime.now.end_of_day
     @step.save!
     @step.toggle_activation
     @step.reload
     assert @step.accept_comments
 
-    @step.start_date = Date.today - 2.days
-    @step.end_date = Date.today - 1.day
+    @step.start_date = DateTime.now - 2.days
+    @step.end_date = DateTime.now - 1.day
     @step.save!
     @step.toggle_activation
     @step.reload
@@ -203,7 +203,7 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'change position to botton if a hidden step becomes visible' do
-    step1 = CommunityTrackPlugin::Step.new(:name => 'Step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today)
+    step1 = CommunityTrackPlugin::Step.new(:name => 'Step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day)
     step1.save!
     @step.hidden = true
     @step.save!
@@ -215,7 +215,7 @@ class StepTest < ActiveSupport::TestCase
 
   should 'decrement lower items positions if a step becomes hidden' do
     @step.save!
-    step1 = CommunityTrackPlugin::Step.new(:name => 'Step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today)
+    step1 = CommunityTrackPlugin::Step.new(:name => 'Step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => DateTime.now.end_of_day, :start_date => DateTime.now.beginning_of_day)
     step1.save!
     assert_equal 2, step1.position
     @step.hidden = true
@@ -225,7 +225,7 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'do not publish a hidden step' do
-    @step.start_date = Date.today
+    @step.start_date = DateTime.now
     @step.hidden = true
     @step.save!
     refute @step.published
@@ -266,7 +266,7 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'enable comments on children when step is activated' do
-    @step.start_date = Date.today
+    @step.start_date = DateTime.now
     @step.save!
     refute @step.accept_comments
     article = fast_create(Article, :parent_id => @step.id, :profile_id => @step.profile.id, :accept_comments => false)
@@ -276,8 +276,7 @@ class StepTest < ActiveSupport::TestCase
   end
 
   should 'enable comments on children when step is active' do
-    @step.start_date = Date.today
-    @step.start_date = Date.today
+    @step.start_date = DateTime.now
     @step.save!
     refute @step.accept_comments
     @step.toggle_activation


=====================================
plugins/event/lib/event_plugin/event_block.rb
=====================================
--- a/plugins/event/lib/event_plugin/event_block.rb
+++ b/plugins/event/lib/event_plugin/event_block.rb
@@ -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
 


=====================================
plugins/event/test/functional/event_block_test.rb
=====================================
--- a/plugins/event/test/functional/event_block_test.rb
+++ b/plugins/event/test/functional/event_block_test.rb
@@ -1,8 +1,9 @@
 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


=====================================
plugins/event/views/blocks/event.html.erb
=====================================
--- a/plugins/event/views/blocks/event.html.erb
+++ b/plugins/event/views/blocks/event.html.erb
@@ -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',


=====================================
public/designs/themes/base/style.scss
=====================================
--- a/public/designs/themes/base/style.scss
+++ b/public/designs/themes/base/style.scss
@@ -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 {


=====================================
test/functional/events_controller_test.rb
=====================================
--- a/test/functional/events_controller_test.rb
+++ b/test/functional/events_controller_test.rb
@@ -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
 


=====================================
test/functional/search_controller_test.rb
=====================================
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -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


=====================================
test/unit/content_viewer_helper_test.rb
=====================================
--- a/test/unit/content_viewer_helper_test.rb
+++ b/test/unit/content_viewer_helper_test.rb
@@ -16,14 +16,14 @@ class ContentViewerHelperTest < ActionView::TestCase
     blog = fast_create(Blog, :name => 'Blog test', :profile_id => profile.id)
     post = create(TextileArticle, :name => 'post test', :profile => profile, :parent => blog)
     result = article_title(post)
-    assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at)
+    assert_tag_in_string result, :tag => 'span', :content => show_time(post.published_at)
   end
 
   should 'display published-at for forum posts' do
     forum = fast_create(Forum, :name => 'Forum test', :profile_id => profile.id)
     post = TextileArticle.create!(:name => 'post test', :profile => profile, :parent => forum)
     result = article_title(post)
-    assert_tag_in_string result, :tag => 'span', :content => show_date(post.published_at)
+    assert_tag_in_string result, :tag => 'span', :content => show_time(post.published_at)
   end
 
   should 'not display published-at for non-blog and non-forum posts' do


=====================================
test/unit/dates_helper_test.rb
=====================================
--- a/test/unit/dates_helper_test.rb
+++ b/test/unit/dates_helper_test.rb
@@ -21,23 +21,23 @@ class DatesHelperTest < ActiveSupport::TestCase
   should 'generate period with two dates' do
     date1 = mock
     date1.stubs(:year).returns('A')
-    expects(:show_date).with(date1, anything).returns('XXX')
+    expects(:show_time).with(date1, anything).returns('XXX')
     date2 = mock
     date2.stubs(:year).returns('B')
-    expects(:show_date).with(date2, anything).returns('YYY')
+    expects(:show_time).with(date2, anything).returns('YYY')
     expects(:_).with('from %{date1} to %{date2}').returns('from %{date1} to %{date2}')
     assert_equal 'from XXX to YYY', show_period(date1, date2)
   end
 
   should 'generate period with in two diferent years' do
-    date1 = Date.new(1920, 1, 2)
-    date2 = Date.new(1992, 4, 6)
-    assert_equal 'from January 2, 1920 to April 6, 1992', show_period(date1, date2)
+    date1 = DateTime.new(1920, 1, 2)
+    date2 = DateTime.new(1992, 4, 6)
+    assert_equal 'from January 2, 1920 0:00 to April 6, 1992 0:00', show_period(date1, date2)
   end
 
   should 'generate period with in two diferent months of the same year' do
-    date1 = Date.new(2013, 2, 1)
-    date2 = Date.new(2013, 3, 1)
+    date1 = DateTime.new(2013, 2, 1)
+    date2 = DateTime.new(2013, 3, 1)
     assert_equal 'from February 1 to March 1, 2013', show_period(date1, date2)
   end
 
@@ -49,13 +49,13 @@ class DatesHelperTest < ActiveSupport::TestCase
 
   should 'generate period with two equal dates' do
     date1 = mock
-    expects(:show_date).with(date1, anything).returns('XXX')
+    expects(:show_time).with(date1, anything).returns('XXX')
     assert_equal 'XXX', show_period(date1, date1)
   end
 
   should 'generate period with one date only' do
     date1 = mock
-    expects(:show_date).with(date1, anything).returns('XXX')
+    expects(:show_time).with(date1, anything).returns('XXX')
     assert_equal 'XXX', show_period(date1)
   end
 
@@ -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
@@ -118,16 +118,16 @@ class DatesHelperTest < ActiveSupport::TestCase
   end
 
   should 'format time' do
-    assert_equal '22 November 2008, 15:34', show_time(Time.mktime(2008, 11, 22, 15, 34, 0, 0))
+    assert_equal 'November 22, 2008 15:34', show_time(Time.mktime(2008, 11, 22, 15, 34, 0, 0))
   end
 
   should 'format time with 2 digits minutes' do
-    assert_equal '22 November 2008, 15:04', show_time(Time.mktime(2008, 11, 22, 15, 04, 0, 0))
+    assert_equal 'November 22, 2008 15:04', show_time(Time.mktime(2008, 11, 22, 15, 04, 0, 0))
   end
 
   should 'translate time' do
     time = Time.parse('25 May 2009, 12:47')
-    assert_equal '25 May 2009, 12:47', show_time(time)
+    assert_equal 'May 25, 2009 12:47', show_time(time)
   end
 
   should 'handle nil time' do


=====================================
test/unit/event_test.rb
=====================================
--- a/test/unit/event_test.rb
+++ b/test/unit/event_test.rb
@@ -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,33 @@ 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>')
+    date = Time.zone.local(2008, 1, 1, 0, 0, 0)
+    event = build(Event, :start_date => date, :end_date => date, :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 +137,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 +150,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 +158,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 +173,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 +183,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 +196,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 +219,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 +237,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 +251,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)


=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -1563,8 +1563,8 @@ class ProfileTest < ActiveSupport::TestCase
 
   should 'list all events' do
     profile = fast_create(Profile)
-    event1 = Event.new(:name => 'Ze Birthday', :start_date => Date.today)
-    event2 = Event.new(:name => 'Mane Birthday', :start_date => Date.today >> 1)
+    event1 = Event.new(:name => 'Ze Birthday', :start_date => DateTime.now)
+    event2 = Event.new(:name => 'Mane Birthday', :start_date => DateTime.now >> 1)
     profile.events << [event1, event2]
     assert_includes profile.events, event1
     assert_includes profile.events, event2
@@ -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)
@@ -1586,7 +1586,7 @@ class ProfileTest < ActiveSupport::TestCase
   should 'list events by month' do
     profile = fast_create(Profile)
 
-    today = Date.new(2014, 03, 2)
+    today = DateTime.new(2014, 03, 2)
     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)
 
@@ -1613,7 +1613,7 @@ class ProfileTest < ActiveSupport::TestCase
   should 'not list events out of range' do
     profile = fast_create(Profile)
 
-    today = Date.today
+    today = DateTime.now
     event_in_range1 = Event.new(:name => 'Foswiki Conference', :start_date => today - 2.day, :end_date => today + 2.day)
     event_in_range2 = Event.new(:name => 'Debian Conference', :start_date => today - 2.day, :end_date => today + 3.day)
     event_out_of_range = Event.new(:name => 'Ze Birthday', :start_date => today - 5.day, :end_date => today - 3.day)
@@ -1627,9 +1627,9 @@ class ProfileTest < ActiveSupport::TestCase
 
   should 'sort events by date' do
     profile = fast_create(Profile)
-    event1 = Event.new(:name => 'Noosfero Hackaton', :start_date => Date.today)
-    event2 = Event.new(:name => 'Debian Day', :start_date => Date.today - 1)
-    event3 = Event.new(:name => 'Fisl 10', :start_date => Date.today + 1)
+    event1 = Event.new(:name => 'Noosfero Hackaton', :start_date => DateTime.now)
+    event2 = Event.new(:name => 'Debian Day', :start_date => DateTime.now - 1)
+    event3 = Event.new(:name => 'Fisl 10', :start_date => DateTime.now + 1)
     profile.events << [event1, event2, event3]
     assert_equal [event2, event1, event3], profile.events
   end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/180ad5296e483134f6df021d56008e75c2e2dc0e...fdf745228a50447a5fd3e22d1f76b5b131c94873
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150813/2667e0c0/attachment-0001.html>


More information about the Noosfero-dev mailing list