Commit 68179b053f3957de23dbd63ddf44288bf038dd80

Authored by Robert Lail
1 parent b5d4395b
Exists in master and in 1 other branch production

use Rails 1.8-style hash keys instead of 1.9

app/controllers/api/v1/notices_controller.rb
... ... @@ -11,12 +11,12 @@ class Api::V1::NoticesController < ApplicationController
11 11 query = {:created_at => {"$lte" => end_date, "$gte" => start_date}}
12 12 end
13 13  
14   - results = benchmark("[api/v1/notices_controller] query time") { Mongoid.master["notices"].find(query, fields: fields).to_a }
  14 + results = benchmark("[api/v1/notices_controller] query time") { Mongoid.master["notices"].find(query, :fields => fields).to_a }
15 15  
16 16 respond_to do |format|
17   - format.html { render json: Yajl.dump(results) } # render JSON if no extension specified on path
18   - format.json { render json: Yajl.dump(results) }
19   - format.xml { render xml: results }
  17 + format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path
  18 + format.json { render :json => Yajl.dump(results) }
  19 + format.xml { render :xml => results }
20 20 end
21 21 end
22 22  
... ...
app/controllers/api/v1/problems_controller.rb
... ... @@ -11,12 +11,12 @@ class Api::V1::ProblemsController < ApplicationController
11 11 query = {:first_notice_at=>{"$lte"=>end_date}, "$or"=>[{:resolved_at=>nil}, {:resolved_at=>{"$gte"=>start_date}}]}
12 12 end
13 13  
14   - results = benchmark("[api/v1/problems_controller] query time") { Mongoid.master["problems"].find(query, fields: fields).to_a }
  14 + results = benchmark("[api/v1/problems_controller] query time") { Mongoid.master["problems"].find(query, :fields => fields).to_a }
15 15  
16 16 respond_to do |format|
17   - format.html { render json: Yajl.dump(results) } # render JSON if no extension specified on path
18   - format.json { render json: Yajl.dump(results) }
19   - format.xml { render xml: results }
  17 + format.html { render :json => Yajl.dump(results) } # render JSON if no extension specified on path
  18 + format.json { render :json => Yajl.dump(results) }
  19 + format.xml { render :xml => results }
20 20 end
21 21 end
22 22  
... ...
spec/controllers/api/v1/problems_controller_spec.rb
... ... @@ -9,26 +9,26 @@ describe Api::V1::ProblemsController do
9 9  
10 10 describe "GET /api/v1/problems" do
11 11 before do
12   - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 02))
13   - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 01), resolved_at: Date.new(2012, 8, 21))
14   - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 21))
15   - Fabricate(:problem, first_notice_at: Date.new(2012, 8, 30))
  12 + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 02))
  13 + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 01), :resolved_at => Date.new(2012, 8, 21))
  14 + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 21))
  15 + Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30))
16 16 end
17 17  
18 18  
19 19  
20 20 it "should return JSON if JSON is requested" do
21   - get :index, auth_token: @user.authentication_token, format: "json"
  21 + get :index, :auth_token => @user.authentication_token, :format => "json"
22 22 lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError)
23 23 end
24 24  
25 25 it "should return XML if XML is requested" do
26   - get :index, auth_token: @user.authentication_token, format: "xml"
  26 + get :index, :auth_token => @user.authentication_token, :format => "xml"
27 27 lambda { XML::Parser.string(response.body).parse }.should_not raise_error
28 28 end
29 29  
30 30 it "should return JSON by default" do
31   - get :index, auth_token: @user.authentication_token
  31 + get :index, :auth_token => @user.authentication_token
32 32 lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError)
33 33 end
34 34  
... ... @@ -37,7 +37,7 @@ describe Api::V1::ProblemsController do
37 37 describe "given a date range" do
38 38  
39 39 it "should return only the problems open during the date range" do
40   - get :index, {auth_token: @user.authentication_token, start_date: "2012-08-20", end_date: "2012-08-27"}
  40 + get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"}
41 41 response.should be_success
42 42 problems = JSON.load response.body
43 43 problems.length.should == 2
... ... @@ -46,7 +46,7 @@ describe Api::V1::ProblemsController do
46 46 end
47 47  
48 48 it "should return all problems" do
49   - get :index, {auth_token: @user.authentication_token}
  49 + get :index, {:auth_token => @user.authentication_token}
50 50 response.should be_success
51 51 problems = JSON.load response.body
52 52 problems.length.should == 4
... ...