From 68179b053f3957de23dbd63ddf44288bf038dd80 Mon Sep 17 00:00:00 2001 From: Robert Lail Date: Tue, 28 Aug 2012 15:13:58 -0500 Subject: [PATCH] use Rails 1.8-style hash keys instead of 1.9 --- app/controllers/api/v1/notices_controller.rb | 8 ++++---- app/controllers/api/v1/problems_controller.rb | 8 ++++---- spec/controllers/api/v1/problems_controller_spec.rb | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/api/v1/notices_controller.rb b/app/controllers/api/v1/notices_controller.rb index 9b2e5f3..6c819ab 100644 --- a/app/controllers/api/v1/notices_controller.rb +++ b/app/controllers/api/v1/notices_controller.rb @@ -11,12 +11,12 @@ class Api::V1::NoticesController < ApplicationController query = {:created_at => {"$lte" => end_date, "$gte" => start_date}} end - results = benchmark("[api/v1/notices_controller] query time") { Mongoid.master["notices"].find(query, fields: fields).to_a } + results = benchmark("[api/v1/notices_controller] query time") { Mongoid.master["notices"].find(query, :fields => fields).to_a } respond_to do |format| - format.html { render json: Yajl.dump(results) } # render JSON if no extension specified on path - format.json { render json: Yajl.dump(results) } - format.xml { render xml: results } + format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path + format.json { render :json => Yajl.dump(results) } + format.xml { render :xml => results } end end diff --git a/app/controllers/api/v1/problems_controller.rb b/app/controllers/api/v1/problems_controller.rb index d25e139..ffb0a1f 100644 --- a/app/controllers/api/v1/problems_controller.rb +++ b/app/controllers/api/v1/problems_controller.rb @@ -11,12 +11,12 @@ class Api::V1::ProblemsController < ApplicationController query = {:first_notice_at=>{"$lte"=>end_date}, "$or"=>[{:resolved_at=>nil}, {:resolved_at=>{"$gte"=>start_date}}]} end - results = benchmark("[api/v1/problems_controller] query time") { Mongoid.master["problems"].find(query, fields: fields).to_a } + results = benchmark("[api/v1/problems_controller] query time") { Mongoid.master["problems"].find(query, :fields => fields).to_a } respond_to do |format| - format.html { render json: Yajl.dump(results) } # render JSON if no extension specified on path - format.json { render json: Yajl.dump(results) } - format.xml { render xml: results } + format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path + format.json { render :json => Yajl.dump(results) } + format.xml { render :xml => results } end end diff --git a/spec/controllers/api/v1/problems_controller_spec.rb b/spec/controllers/api/v1/problems_controller_spec.rb index 15f797d..f646b6b 100644 --- a/spec/controllers/api/v1/problems_controller_spec.rb +++ b/spec/controllers/api/v1/problems_controller_spec.rb @@ -9,26 +9,26 @@ describe Api::V1::ProblemsController do describe "GET /api/v1/problems" do before do - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 02)) - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 21)) - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 21)) - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 30)) + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 02)) + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 21)) + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 21)) + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) end it "should return JSON if JSON is requested" do - get :index, auth_token: @user.authentication_token, format: "json" + get :index, :auth_token => @user.authentication_token, :format => "json" lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) end it "should return XML if XML is requested" do - get :index, auth_token: @user.authentication_token, format: "xml" + get :index, :auth_token => @user.authentication_token, :format => "xml" lambda { XML::Parser.string(response.body).parse }.should_not raise_error end it "should return JSON by default" do - get :index, auth_token: @user.authentication_token + get :index, :auth_token => @user.authentication_token lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) end @@ -37,7 +37,7 @@ describe Api::V1::ProblemsController do describe "given a date range" do it "should return only the problems open during the date range" do - get :index, {auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27"} + get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} response.should be_success problems = JSON.load response.body problems.length.should == 2 @@ -46,7 +46,7 @@ describe Api::V1::ProblemsController do end it "should return all problems" do - get :index, {auth_token: @user.authentication_token} + get :index, {:auth_token => @user.authentication_token} response.should be_success problems = JSON.load response.body problems.length.should == 4 -- libgit2 0.21.2