Commit 3e132ada6452742d5472d1c6218b792666df1cef
1 parent
d6f2faeb
Exists in
master
and in
1 other branch
Fixed specs for 1.8.7. (1.8 style hashes, and replace Time.new with DateTime)
Showing
1 changed file
with
21 additions
and
25 deletions
Show diff stats
spec/controllers/api/v1/notices_controller_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | -describe Api::V1::NoticesController do | ||
4 | - | 3 | +describe Api::V1::NoticesController do |
4 | + | ||
5 | context "when logged in" do | 5 | context "when logged in" do |
6 | before do | 6 | before do |
7 | @user = Fabricate(:user) | 7 | @user = Fabricate(:user) |
8 | end | 8 | end |
9 | - | 9 | + |
10 | describe "GET /api/v1/notices" do | 10 | describe "GET /api/v1/notices" do |
11 | before do | 11 | before do |
12 | - Fabricate(:notice, created_at: Time.new(2012, 8, 01)) | ||
13 | - Fabricate(:notice, created_at: Time.new(2012, 8, 01)) | ||
14 | - Fabricate(:notice, created_at: Time.new(2012, 8, 21)) | ||
15 | - Fabricate(:notice, created_at: Time.new(2012, 8, 30)) | 12 | + Fabricate(:notice, :created_at => DateTime.new(2012, 8, 01)) |
13 | + Fabricate(:notice, :created_at => DateTime.new(2012, 8, 01)) | ||
14 | + Fabricate(:notice, :created_at => DateTime.new(2012, 8, 21)) | ||
15 | + Fabricate(:notice, :created_at => DateTime.new(2012, 8, 30)) | ||
16 | end | 16 | end |
17 | - | ||
18 | - | ||
19 | - | 17 | + |
20 | it "should return JSON if JSON is requested" do | 18 | it "should return JSON if JSON is requested" do |
21 | - get :index, auth_token: @user.authentication_token, format: "json" | 19 | + get :index, :auth_token => @user.authentication_token, :format => "json" |
22 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) | 20 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) |
23 | end | 21 | end |
24 | - | 22 | + |
25 | it "should return XML if XML is requested" do | 23 | it "should return XML if XML is requested" do |
26 | - get :index, auth_token: @user.authentication_token, format: "xml" | 24 | + get :index, :auth_token => @user.authentication_token, :format => "xml" |
27 | lambda { XML::Parser.string(response.body).parse }.should_not raise_error | 25 | lambda { XML::Parser.string(response.body).parse }.should_not raise_error |
28 | end | 26 | end |
29 | - | 27 | + |
30 | it "should return JSON by default" do | 28 | it "should return JSON by default" do |
31 | - get :index, auth_token: @user.authentication_token | 29 | + get :index, :auth_token => @user.authentication_token |
32 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) | 30 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) |
33 | end | 31 | end |
34 | - | ||
35 | - | ||
36 | - | 32 | + |
37 | describe "given a date range" do | 33 | describe "given a date range" do |
38 | - | 34 | + |
39 | it "should return only the notices created during the date range" do | 35 | it "should return only the notices created during the date range" do |
40 | - get :index, {auth_token: @user.authentication_token, start_date: "2012-08-01", end_date: "2012-08-27"} | 36 | + get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27"} |
41 | response.should be_success | 37 | response.should be_success |
42 | notices = JSON.load response.body | 38 | notices = JSON.load response.body |
43 | notices.length.should == 3 | 39 | notices.length.should == 3 |
44 | end | 40 | end |
45 | - | 41 | + |
46 | end | 42 | end |
47 | - | 43 | + |
48 | it "should return all notices" do | 44 | it "should return all notices" do |
49 | - get :index, {auth_token: @user.authentication_token} | 45 | + get :index, {:auth_token => @user.authentication_token} |
50 | response.should be_success | 46 | response.should be_success |
51 | notices = JSON.load response.body | 47 | notices = JSON.load response.body |
52 | notices.length.should == 4 | 48 | notices.length.should == 4 |
53 | end | 49 | end |
54 | - | 50 | + |
55 | end | 51 | end |
56 | end | 52 | end |
57 | - | 53 | + |
58 | end | 54 | end |