Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

filter previous and next quuarter

  • Loading branch information...
commit a38a5baba40bb85acc7f9a1c01607239a7bc2058 1 parent 146665c
@koos koos authored
View
1  app/controllers/application_controller.rb
@@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
+ # @current_user = User.first
end
def admin_required
View
7 app/controllers/points_controller.rb
@@ -3,9 +3,10 @@ class PointsController < ApplicationController
skip_before_filter :user_required, :only => [:howto]
def index
- from = Date.today.beginning_of_quarter
- to = Date.today.end_of_quarter
- @points = Point.where("created_at >= ?",from).where("created_at < ?",to)
+ @date = params[:date].blank? ? Date.today : Date.parse(params[:date])
+ @from = @date.beginning_of_quarter
+ @to = @date.end_of_quarter
+ @points = Point.where("created_at >= ?",@from).where("created_at < ?",@to)
end
def new
View
4 app/views/points/index.html.erb
@@ -1,5 +1,9 @@
<h1>List of points</h1>
+<%= link_to 'previous quarter', points_url(:date => @date-3.months) %>
+<%= link_to 'next quarter', points_url(:date => @date+3.months) %>
+
+Quarter - From: <%= @from %>, To: <%= @to %>
<table border=1>
<thead>
<tr>
View
8 spec/controllers/points_controller_spec.rb
@@ -106,6 +106,14 @@
response.body.should include("User/Category")
response.body.should include("Subcategories")
end
+
+ it "should render successfuly the points by date" do
+ get :index, :date => "2012-04-04"
+ response.body.should include("<table border=1>")
+ response.body.should include("User/Category")
+ response.body.should include("Subcategories")
+ response.body.should include("Quarter - From: 2012-04-01, To: 2012-06-30")
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.