[Git][noosfero/noosfero][master] 2 commits: Fixing range in events list

Tallys Martins gitlab at mg.gitlab.com
Thu Apr 20 13:30:55 BRT 2017


Tallys Martins pushed to branch master at Noosfero / noosfero


Commits:
d7fbb4a0 by Victor Navarro at 2017-04-20T12:50:56-03:00
Fixing range in events list

- - - - -
898e8da2 by Tallys Martins at 2017-04-20T16:30:43+00:00
Merge branch 'fix_agenda' into 'master'

Fix agenda

See merge request !1172
- - - - -


2 changed files:

- app/models/event.rb
- test/functional/events_controller_test.rb


Changes:

=====================================
app/models/event.rb
=====================================
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -41,8 +41,9 @@ class Event < Article
 
   scope :next_events_from_month, -> date {
     date_temp = date.strftime("%Y-%m-%d")
+    final_day = date.at_end_of_month
     order('start_date ASC')
-    .where("start_date >= ?","#{date_temp}")
+    .where("start_date >= ? AND start_date <= ?", "#{date_temp}", "#{final_day}")
   }
 
   scope :by_month, -> date {


=====================================
test/functional/events_controller_test.rb
=====================================
--- a/test/functional/events_controller_test.rb
+++ b/test/functional/events_controller_test.rb
@@ -46,6 +46,16 @@ class EventsControllerTest < ActionController::TestCase
     assert_equal 20, assigns(:events).size
   end
 
+  should "show events for current month only" do
+    profile.events << Event.create(:name => 'Maria Birthday', :start_date => DateTime.now.at_end_of_month - 1)
+    profile.events << Event.create(:name => 'Joao Birthday', :start_date => DateTime.now + 31)
+
+    get :events, :profile => profile.identifier
+
+    assert_no_tag :tag =>'a', :content => /Joao Birthday/
+    assert_tag :tag =>'a', :content => /Maria Birthday/
+  end
+
   should 'show events of specific day' do
     profile.events << Event.new(:name => 'Joao Birthday', :start_date => DateTime.new(2009, 10, 28))
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/8d44ed10b4b26ac9a5662ed0890ac96bdd51f232...898e8da29b9162c5c69fd290a992f27dc8b3c18a

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/8d44ed10b4b26ac9a5662ed0890ac96bdd51f232...898e8da29b9162c5c69fd290a992f27dc8b3c18a
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170420/a89529a8/attachment-0001.html>


More information about the Noosfero-dev mailing list