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 | 1 | require 'spec_helper' |
2 | 2 | |
3 | -describe Api::V1::NoticesController do | |
4 | - | |
3 | +describe Api::V1::NoticesController do | |
4 | + | |
5 | 5 | context "when logged in" do |
6 | 6 | before do |
7 | 7 | @user = Fabricate(:user) |
8 | 8 | end |
9 | - | |
9 | + | |
10 | 10 | describe "GET /api/v1/notices" do |
11 | 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 | 16 | end |
17 | - | |
18 | - | |
19 | - | |
17 | + | |
20 | 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 | 20 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) |
23 | 21 | end |
24 | - | |
22 | + | |
25 | 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 | 25 | lambda { XML::Parser.string(response.body).parse }.should_not raise_error |
28 | 26 | end |
29 | - | |
27 | + | |
30 | 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 | 30 | lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) |
33 | 31 | end |
34 | - | |
35 | - | |
36 | - | |
32 | + | |
37 | 33 | describe "given a date range" do |
38 | - | |
34 | + | |
39 | 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 | 37 | response.should be_success |
42 | 38 | notices = JSON.load response.body |
43 | 39 | notices.length.should == 3 |
44 | 40 | end |
45 | - | |
41 | + | |
46 | 42 | end |
47 | - | |
43 | + | |
48 | 44 | it "should return all notices" do |
49 | - get :index, {auth_token: @user.authentication_token} | |
45 | + get :index, {:auth_token => @user.authentication_token} | |
50 | 46 | response.should be_success |
51 | 47 | notices = JSON.load response.body |
52 | 48 | notices.length.should == 4 |
53 | 49 | end |
54 | - | |
50 | + | |
55 | 51 | end |
56 | 52 | end |
57 | - | |
53 | + | |
58 | 54 | end | ... | ... |