introspective_grape 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +5 -52
  3. data/CHANGELOG.md +46 -0
  4. data/Gemfile +2 -0
  5. data/README.md +15 -0
  6. data/gemfiles/{Gemfile.rails.4.2.7.1 → Gemfile.rails.5.0.0} +5 -4
  7. data/gemfiles/Gemfile.rails.5.0.1 +1 -0
  8. data/gemfiles/{Gemfile.rails.4.2.7.1.new.swagger → Gemfile.rails.5.1.0} +5 -3
  9. data/gemfiles/{Gemfile.rails.3.2.22 → Gemfile.rails.5.2.0} +5 -4
  10. data/gemfiles/Gemfile.rails.master +1 -0
  11. data/introspective_grape.gemspec +15 -13
  12. data/lib/introspective_grape.rb +1 -1
  13. data/lib/introspective_grape/api.rb +38 -31
  14. data/lib/introspective_grape/camel_snake.rb +30 -31
  15. data/lib/introspective_grape/create_helpers.rb +8 -3
  16. data/lib/introspective_grape/version.rb +1 -1
  17. data/spec/dummy/Gemfile +6 -3
  18. data/spec/dummy/app/api/api_helpers.rb +2 -0
  19. data/spec/dummy/app/api/dummy/company_api.rb +1 -1
  20. data/spec/dummy/app/models/image.rb +1 -1
  21. data/spec/dummy/app/models/role.rb +1 -1
  22. data/spec/dummy/app/models/user.rb +2 -2
  23. data/spec/dummy/config.ru +12 -0
  24. data/spec/dummy/config/application.rb +1 -1
  25. data/spec/dummy/config/environments/development.rb +3 -3
  26. data/spec/dummy/config/initializers/paperclip_adapter.rb +1 -1
  27. data/spec/dummy/db/migrate/20190325231304_add_test_data.rb +5 -0
  28. data/spec/dummy/db/schema.rb +154 -173
  29. data/spec/requests/chat_api_spec.rb +26 -26
  30. data/spec/requests/company_api_spec.rb +15 -15
  31. data/spec/requests/location_api_spec.rb +18 -18
  32. data/spec/requests/project_api_spec.rb +21 -21
  33. data/spec/requests/role_api_spec.rb +4 -4
  34. data/spec/requests/sessions_api_spec.rb +10 -10
  35. data/spec/requests/swagger_spec.rb +1 -1
  36. data/spec/requests/user_api_spec.rb +34 -34
  37. metadata +33 -44
  38. data/gemfiles/2.0.0-Gemfile +0 -22
  39. data/gemfiles/2.2.0-Gemfile +0 -21
  40. data/gemfiles/Gemfile.rails.4.1.13 +0 -13
  41. data/gemfiles/Gemfile.rails.4.2.8 +0 -12
@@ -31,7 +31,7 @@ describe Dummy::ChatAPI, type: :request do
31
31
 
32
32
  it "should return a list of a user's chats" do
33
33
  get "/api/v1/chats"
34
- response.should be_success
34
+ response.should be_successful
35
35
  json.size.should == 2
36
36
  json.first['creator_id'].to_i.should == @sender.id
37
37
  json.first['users'].size.should == Chat.find(json.first['id']).users.size
@@ -40,20 +40,20 @@ describe Dummy::ChatAPI, type: :request do
40
40
  context :notifications do
41
41
  it "should get new chat notifications" do
42
42
  get "/api/v1/chats/notifications/"
43
- response.should be_success
43
+ response.should be_successful
44
44
  json.keys.size.should == 1
45
45
  json[@pm.id.to_s].should == 3
46
46
  end
47
47
 
48
48
  it "should get new chat notifications for a particular chat" do
49
- get "/api/v1/chats/notifications/", id: @pm.id
50
- response.should be_success
49
+ get "/api/v1/chats/notifications/", params: { id: @pm.id }
50
+ response.should be_successful
51
51
  json[@pm.id.to_s].should == 3
52
52
  end
53
53
 
54
54
  it "should return 0 for non-existent chats" do
55
- get "/api/v1/chats/notifications/", id: 0
56
- response.should be_success
55
+ get "/api/v1/chats/notifications/", params: { id: 0 }
56
+ response.should be_successful
57
57
  json['0'].should == 0
58
58
  end
59
59
  end
@@ -61,23 +61,23 @@ describe Dummy::ChatAPI, type: :request do
61
61
  context :messages do
62
62
 
63
63
  it "should get no new chat messages if user was last to reply" do
64
- get "/api/v1/chats/messages", id: @chat.id, new: true
65
- response.should be_success
64
+ get "/api/v1/chats/messages", params: { id: @chat.id, new: true }
65
+ response.should be_successful
66
66
  json.size.should == 0
67
67
  end
68
68
 
69
69
  it "should get new chat messages if user recieves another reply" do
70
70
  @sender.reply(@chat, "And now for something completely different.")
71
- get "/api/v1/chats/messages", id: @chat.id, new: true
72
- response.should be_success
71
+ get "/api/v1/chats/messages", params: { id: @chat.id, new: true }
72
+ response.should be_successful
73
73
  json.size.should == 1
74
74
  end
75
75
 
76
76
  it "should mark all new messages from all chats as read if mark_as_read is true" do
77
77
  @sender.reply(@chat, 'A new response.')
78
78
  @current_user.new_messages?.keys.size.should == 2
79
- get "/api/v1/chats/messages", new: true, mark_as_read: true
80
- response.should be_success
79
+ get "/api/v1/chats/messages", params: { new: true, mark_as_read: true }
80
+ response.should be_successful
81
81
  json.size.should == 4
82
82
  @current_user.new_messages?.keys.size.should == 0
83
83
  end
@@ -86,8 +86,8 @@ describe Dummy::ChatAPI, type: :request do
86
86
 
87
87
  context :users do
88
88
  it "should list the users in a chat" do
89
- get "/api/v1/chats/users", id: @chat.id
90
- response.should be_success
89
+ get "/api/v1/chats/users", params: { id: @chat.id }
90
+ response.should be_successful
91
91
  json.size.should == 3
92
92
  json.map{|u| u['email']}.sort.should == [ "current_user@springshot.com", "lurker@springshot.com", "sender@springshot.com" ]
93
93
  end
@@ -95,8 +95,8 @@ describe Dummy::ChatAPI, type: :request do
95
95
  it "should add a new user to a chat" do
96
96
  new_user1 = User.make
97
97
  new_user1.save!
98
- post "/api/v1/chats/users", id: @chat.id, user_ids: new_user1.id
99
- response.should be_success
98
+ post "/api/v1/chats/users", params: { id: @chat.id, user_ids: new_user1.id }
99
+ response.should be_successful
100
100
  json['status'].should == true
101
101
  @chat.reload
102
102
  @chat.active_users.include?(new_user1).should == true
@@ -107,8 +107,8 @@ describe Dummy::ChatAPI, type: :request do
107
107
  new_user2 = User.make
108
108
  new_user1.save!
109
109
  new_user2.save!
110
- post "/api/v1/chats/users", id: @chat.id, user_ids: "#{new_user1.id},#{new_user2.id}"
111
- response.should be_success
110
+ post "/api/v1/chats/users", params: { id: @chat.id, user_ids: "#{new_user1.id},#{new_user2.id}" }
111
+ response.should be_successful
112
112
  json['status'].should == true
113
113
  @chat.reload
114
114
  @chat.active_users.include?(new_user1).should == true
@@ -117,7 +117,7 @@ describe Dummy::ChatAPI, type: :request do
117
117
 
118
118
  it "should be invalid to add an already active chat member to a chat" do
119
119
  @chat.chat_users.size.should == 3
120
- post "/api/v1/chats/users", id: @chat.id, user_ids: @chat.active_users.first.id
120
+ post "/api/v1/chats/users", params: { id: @chat.id, user_ids: @chat.active_users.first.id }
121
121
  response.status.should == 400
122
122
  json['error'].should == "#{@chat.active_users.first.name} is already present in this chat."
123
123
  @chat.reload
@@ -125,7 +125,7 @@ describe Dummy::ChatAPI, type: :request do
125
125
  end
126
126
 
127
127
  it "should raise an error when an outsider tries to add themselves to a chat" do
128
- post "/api/v1/chats/users", id: @lurk.id, user_ids: @current_user.id
128
+ post "/api/v1/chats/users", params: { id: @lurk.id, user_ids: @current_user.id }
129
129
  response.status.should == 400
130
130
  json['error'].should == 'Only current chat participants can add users.'
131
131
  @lurk.reload
@@ -136,8 +136,8 @@ describe Dummy::ChatAPI, type: :request do
136
136
 
137
137
  context :chat do
138
138
  it "should start a new chat" do
139
- post "/api/v1/chats", user_ids:@lurker.id, message: 'a new chat'
140
- response.should be_success
139
+ post "/api/v1/chats", params: { user_ids:@lurker.id, message: 'a new chat' }
140
+ response.should be_successful
141
141
  json['creator_id'].should == @current_user.id
142
142
  Chat.last.creator.should == @current_user
143
143
  Chat.last.messages.map(&:message).first.should == 'a new chat'
@@ -145,8 +145,8 @@ describe Dummy::ChatAPI, type: :request do
145
145
  end
146
146
 
147
147
  it "should reply to a chat" do
148
- put "/api/v1/chats/#{@chat.id}", message: 'A reply.'
149
- response.should be_success
148
+ put "/api/v1/chats/#{@chat.id}", params: { message: 'A reply.' }
149
+ response.should be_successful
150
150
  ChatMessage.last.author.should == @current_user
151
151
  @sender.read_messages(Chat.last.id ).last.message.should == 'A reply.'
152
152
  @lurker.read_messages(Chat.last.id ).last.message.should == 'A reply.'
@@ -154,7 +154,7 @@ describe Dummy::ChatAPI, type: :request do
154
154
 
155
155
  it "should leave a chat" do
156
156
  delete "/api/v1/chats/#{@chat.id}"
157
- response.should be_success
157
+ response.should be_successful
158
158
  json['status'].should == true
159
159
  @chat.reload
160
160
  @chat.active_users.include?(@current_user).should == false
@@ -163,7 +163,7 @@ describe Dummy::ChatAPI, type: :request do
163
163
  it "should only allow chat participants to reply" do
164
164
  @current_user.leave_chat(@chat)
165
165
  @current_user.reload
166
- put "/api/v1/chats/#{@chat.id}", message: "I'm an interloper"
166
+ put "/api/v1/chats/#{@chat.id}", params: { message: "I'm an interloper" }
167
167
  response.status.should == 400
168
168
  json['error'].should == 'Messages: is invalid'
169
169
  @chat.messages.last.should_not == "I'm an interloper"
@@ -4,13 +4,13 @@ describe Dummy::CompanyAPI, type: :request do
4
4
  context :default_values do
5
5
  it "should respect default values" do
6
6
  get '/api/v1/companies/special/list'
7
- response.should be_success
7
+ response.should be_successful
8
8
  json.should eq({"boolean_default"=>false, "string_default"=>"foo", "integer_default"=>123})
9
9
  end
10
10
 
11
11
  it "should override default values" do
12
- get '/api/v1/companies/special/list', boolean_default: true, string_default: 'bar', integer_default: 321
13
- response.should be_success
12
+ get '/api/v1/companies/special/list', params: { boolean_default: true, string_default: 'bar', integer_default: 321 }
13
+ response.should be_successful
14
14
  json.should eq({"boolean_default"=>true, "string_default"=>"bar", "integer_default"=>321})
15
15
  end
16
16
  end
@@ -22,7 +22,7 @@ describe Dummy::CompanyAPI, type: :request do
22
22
 
23
23
  get '/api/v1/companies'
24
24
 
25
- response.should be_success
25
+ response.should be_successful
26
26
  json.length.should eq 25
27
27
  json.first['id'].should eq Company.first.id
28
28
  response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["30", "2", "25", "1", "2", "", "0"]
@@ -37,14 +37,14 @@ describe Dummy::CompanyAPI, type: :request do
37
37
 
38
38
  it "should return a list of companies" do
39
39
  get '/api/v1/companies'
40
- response.should be_success
40
+ response.should be_successful
41
41
  json.length.should > 0
42
42
  json.map{|c| c['id'].to_i}.include?(company.id).should == true
43
43
  end
44
44
 
45
45
  it "should return the specified company" do
46
46
  get "/api/v1/companies/#{company.id}"
47
- response.should be_success
47
+ response.should be_successful
48
48
  json['name'].should == company.name
49
49
  end
50
50
 
@@ -55,14 +55,14 @@ describe Dummy::CompanyAPI, type: :request do
55
55
 
56
56
 
57
57
  it "should create a company" do
58
- post "/api/v1/companies", { name: 'Test 123', short_name: 'T123' }
59
- response.should be_success
58
+ post "/api/v1/companies", params: { name: 'Test 123', short_name: 'T123' }
59
+ response.should be_successful
60
60
  json['name'].should == "Test 123"
61
61
  json['short_name'].should == "T123"
62
62
  end
63
63
 
64
64
  it "should validate a new company" do
65
- post "/api/v1/companies", { name: 'a'*257, short_name: 'a'*11 }
65
+ post "/api/v1/companies", params: { name: 'a'*257, short_name: 'a'*11 }
66
66
  response.code.should == "400"
67
67
  json['error'].should == "Name: is too long (maximum is 256 characters), Short Name: is too long (maximum is 10 characters)"
68
68
  end
@@ -70,8 +70,8 @@ describe Dummy::CompanyAPI, type: :request do
70
70
 
71
71
  it "should update the company" do
72
72
  new_name = 'New Test 1234'
73
- put "/api/v1/companies/#{company.id}", { name: new_name }
74
- response.should be_success
73
+ put "/api/v1/companies/#{company.id}", params: { name: new_name }
74
+ response.should be_successful
75
75
  company.reload
76
76
  company.name.should == new_name
77
77
  json['name'].should == new_name
@@ -79,7 +79,7 @@ describe Dummy::CompanyAPI, type: :request do
79
79
 
80
80
  it "should validate the company on update" do
81
81
  old_name = company.name
82
- put "/api/v1/companies/#{company.id}", { name: 'a'*257, short_name: 'a'*11 }
82
+ put "/api/v1/companies/#{company.id}", params: { name: 'a'*257, short_name: 'a'*11 }
83
83
  response.code.should == "400"
84
84
  company.reload
85
85
  company.name.should == old_name
@@ -87,17 +87,17 @@ describe Dummy::CompanyAPI, type: :request do
87
87
  end
88
88
 
89
89
  it "should validate json parameters" do
90
- put "/api/v1/companies/#{company.id}", { gizmos: "garbage" }
90
+ put "/api/v1/companies/#{company.id}", params: { gizmos: "garbage" }
91
91
  json["error"].should eq "gizmos must be valid JSON!"
92
92
  end
93
93
 
94
94
  it "should validate json array parameters" do
95
- put "/api/v1/companies/#{company.id}", { widgets: "[garbage[\"A\",\"B\"]" }
95
+ put "/api/v1/companies/#{company.id}", params: { widgets: "[garbage[\"A\",\"B\"]" }
96
96
  json["error"].should eq "widgets must be a valid JSON array!"
97
97
  end
98
98
 
99
99
  it "should validate json hash parameters" do
100
- put "/api/v1/companies/#{company.id}", { sprockets: "{\"foo\":\"bar\"}garbage}" }
100
+ put "/api/v1/companies/#{company.id}", params: { sprockets: "{\"foo\":\"bar\"}garbage}" }
101
101
  json["error"].should eq "sprockets must be a valid JSON hash!"
102
102
  end
103
103
 
@@ -13,7 +13,7 @@ describe Dummy::LocationAPI, type: :request do
13
13
 
14
14
  it "should return an array of camelized location entities" do
15
15
  get '/api/v1/locations'
16
- response.should be_success
16
+ response.should be_successful
17
17
  j = JSON.parse(response.body)
18
18
  j.each {|l| l.key?('childLocations').should be_truthy }
19
19
  j.each {|l| l.key?('parentLocationId').should be_truthy }
@@ -23,7 +23,7 @@ describe Dummy::LocationAPI, type: :request do
23
23
 
24
24
  it "should return a list of top level locations and their children" do
25
25
  get '/api/v1/locations'
26
- response.should be_success
26
+ response.should be_successful
27
27
  json.length.should eq 2
28
28
  json.map{|l| l['id'].to_i }.include?(location.id).should == true
29
29
 
@@ -33,15 +33,15 @@ describe Dummy::LocationAPI, type: :request do
33
33
 
34
34
 
35
35
  it "should generate basic filters on the whitelisted model attributes" do
36
- get '/api/v1/locations', { name: "TEST" }
37
- response.should be_success
36
+ get '/api/v1/locations', params: { name: "TEST" }
37
+ response.should be_successful
38
38
  json.length.should eq 1
39
39
  json.first['name'].should eq "TEST"
40
40
  end
41
41
 
42
42
  it "should parse more advanced JSON filters" do
43
- get '/api/v1/locations', filter: "{\"child_locations_locations\":{\"name\":\"Terminal A\"}}"
44
- response.should be_success
43
+ get '/api/v1/locations', params: { filter: "{\"child_locations_locations\":{\"name\":\"Terminal A\"}}" }
44
+ response.should be_successful
45
45
  json.length.should eq 1
46
46
  json.first['child_locations'].length.should eq 1
47
47
  json.first['child_locations'].first['name'].should eq "Terminal A"
@@ -49,7 +49,7 @@ describe Dummy::LocationAPI, type: :request do
49
49
 
50
50
  it "should return the specified location" do
51
51
  get "/api/v1/locations/#{location.id}"
52
- response.should be_success
52
+ response.should be_successful
53
53
  json['name'].should == location.name
54
54
  end
55
55
 
@@ -59,15 +59,15 @@ describe Dummy::LocationAPI, type: :request do
59
59
  end
60
60
 
61
61
  it "should create a location" do
62
- post "/api/v1/locations", { name: 'Test 123', kind: "terminal" }
63
- response.should be_success
62
+ post "/api/v1/locations", params: { name: 'Test 123', kind: "terminal" }
63
+ response.should be_successful
64
64
  json['name'].should == "Test 123"
65
65
  end
66
66
 
67
67
  it "should create a location with a beacon" do
68
68
  b = LocationBeacon.make(company: Company.last)
69
- post "/api/v1/locations", { name: 'Test 123', kind: "gate", beacons_attributes: [ b.attributes ] }
70
- response.should be_success
69
+ post "/api/v1/locations", params: { name: 'Test 123', kind: "gate", beacons_attributes: [ b.attributes ] }
70
+ response.should be_successful
71
71
  json['name'].should == "Test 123"
72
72
  l = Location.find(json['id'])
73
73
  created = l.beacons.first
@@ -78,8 +78,8 @@ describe Dummy::LocationAPI, type: :request do
78
78
 
79
79
  it "should create a location with gps coordinates" do
80
80
  gps = LocationGps.make
81
- post "/api/v1/locations", { name: 'Test 123', kind: "airport", gps_attributes: gps.attributes }
82
- response.should be_success
81
+ post "/api/v1/locations", params: { name: 'Test 123', kind: "airport", gps_attributes: gps.attributes }
82
+ response.should be_successful
83
83
  json['name'].should == "Test 123"
84
84
  l = Location.find(json['id'])
85
85
  created = l.gps
@@ -90,15 +90,15 @@ describe Dummy::LocationAPI, type: :request do
90
90
  end
91
91
 
92
92
  it "should validate a new location" do
93
- post "/api/v1/locations", { name: 'test' }
93
+ post "/api/v1/locations", params: { name: 'test' }
94
94
  response.code.should == "400"
95
95
  json['error'].should == "Kind: is not included in the list"
96
96
  end
97
97
 
98
98
  it "should update the location" do
99
99
  new_name = 'New Test 1234'
100
- put "/api/v1/locations/#{location.id}", { name: new_name }
101
- response.should be_success
100
+ put "/api/v1/locations/#{location.id}", params: { name: new_name }
101
+ response.should be_successful
102
102
  location.reload
103
103
  location.name.should == new_name
104
104
  json['name'].should == new_name
@@ -106,7 +106,7 @@ describe Dummy::LocationAPI, type: :request do
106
106
 
107
107
  it "should validate the location on update" do
108
108
  old_kind = location.kind
109
- put "/api/v1/locations/#{location.id}", { kind: 'bring the noise' }
109
+ put "/api/v1/locations/#{location.id}", params: { kind: 'bring the noise' }
110
110
  response.code.should == "400"
111
111
  location.reload
112
112
  location.kind.should == old_kind
@@ -116,7 +116,7 @@ describe Dummy::LocationAPI, type: :request do
116
116
  it "should destroy the location and all of its child and grandchild locations" do
117
117
  child_locations = location.child_locations.map {|l| [l.id, l.child_locations.map(&:id)] }.flatten
118
118
  delete "/api/v1/locations/#{location.id}"
119
- response.should be_success
119
+ response.should be_successful
120
120
  Location.find_by_id(location.id).should == nil
121
121
  Location.where(id: child_locations).size.should == 0
122
122
  end
@@ -24,15 +24,15 @@ describe Dummy::ProjectAPI, type: :request do
24
24
 
25
25
  context "As a super admin" do
26
26
  it "should return a list of all projects" do
27
- get '/api/v1/projects', per_page: 10, offset: 0
28
- response.should be_success
27
+ get '/api/v1/projects', params: { per_page: 10, offset: 0 }
28
+ response.should be_successful
29
29
  json.length.should == Project.count
30
30
  json.map{|c| c['id'].to_i}.include?(project.id).should == true
31
31
  end
32
32
 
33
33
  it "should return the specified project" do
34
34
  get "/api/v1/projects/#{project.id}"
35
- response.should be_success
35
+ response.should be_successful
36
36
  json['name'].should == project.name
37
37
  end
38
38
 
@@ -56,8 +56,8 @@ describe Dummy::ProjectAPI, type: :request do
56
56
  p = {
57
57
  name: 'New Team', team_users_attributes: [{ user_id: @u1.id }, { user_id: @u2.id }]
58
58
  }
59
- post "/api/v1/projects/#{project.id}/teams", p
60
- response.should be_success
59
+ post "/api/v1/projects/#{project.id}/teams", params: p
60
+ response.should be_successful
61
61
  Team.last.name.should == 'New Team'
62
62
  Team.last.users.to_a.should == [@u1,@u2]
63
63
  end
@@ -66,8 +66,8 @@ describe Dummy::ProjectAPI, type: :request do
66
66
  p = { team_users_attributes: [
67
67
  { user_id: @u1.id }, { user_id: @u2.id }
68
68
  ] }
69
- put "/api/v1/projects/#{project.id}/teams/#{@team.id}", p
70
- response.should be_success
69
+ put "/api/v1/projects/#{project.id}/teams/#{@team.id}", params: p
70
+ response.should be_successful
71
71
 
72
72
  Team.last.users.to_a.should == [@u1,@u2]
73
73
  end
@@ -78,8 +78,8 @@ describe Dummy::ProjectAPI, type: :request do
78
78
  p = { team_users_attributes: [
79
79
  { id: @team.team_users.where(user_id:@u1.id).first.id, _destroy: 1 }
80
80
  ] }
81
- put "/api/v1/projects/#{project.id}/teams/#{@team.id}", p
82
- response.should be_success
81
+ put "/api/v1/projects/#{project.id}/teams/#{@team.id}", params: p
82
+ response.should be_successful
83
83
  Team.last.users.to_a.should == [@u2]
84
84
  end
85
85
  end
@@ -87,8 +87,8 @@ describe Dummy::ProjectAPI, type: :request do
87
87
  context "edit a project team via nested routes" do
88
88
  it "should add a team member" do
89
89
  p = { user_id: @u1.id }
90
- post "/api/v1/projects/#{project.id}/teams/#{@team.id}/team_users", p
91
- response.should be_success
90
+ post "/api/v1/projects/#{project.id}/teams/#{@team.id}/team_users", params: p
91
+ response.should be_successful
92
92
  Team.last.users.to_a.should == [@u1]
93
93
  end
94
94
 
@@ -97,7 +97,7 @@ describe Dummy::ProjectAPI, type: :request do
97
97
  @team.save!
98
98
  id = @team.team_users.where(user_id:@u1.id).first.id
99
99
  delete "/api/v1/projects/#{project.id}/teams/#{@team.id}/team_users/#{id}"
100
- response.should be_success
100
+ response.should be_successful
101
101
  Team.last.users.to_a.should == [@u2]
102
102
  end
103
103
  end
@@ -118,8 +118,8 @@ describe Dummy::ProjectAPI, type: :request do
118
118
  end
119
119
 
120
120
  it "should return a list of all the company's projects" do
121
- get '/api/v1/projects', offset: 0
122
- response.should be_success
121
+ get '/api/v1/projects', params: { offset: 0 }
122
+ response.should be_successful
123
123
  json.length.should == 2
124
124
  json.map{|c| c['name']}.include?("Manufacture Sprockets").should == true
125
125
  json.map{|c| c['name']}.include?("Disassemble Sprockets").should == true
@@ -140,8 +140,8 @@ describe Dummy::ProjectAPI, type: :request do
140
140
  end
141
141
 
142
142
  it "should return a list of all the project admin's projects" do
143
- get '/api/v1/projects', offset: 0
144
- response.should be_success
143
+ get '/api/v1/projects', params: { offset: 0 }
144
+ response.should be_successful
145
145
  json.length.should == 1
146
146
  json.map{|c| c['name']}.include?("Manufacture Sprockets").should == true
147
147
  json.map{|c| c['name']}.include?("Disassemble Sprockets").should == false
@@ -156,7 +156,7 @@ describe Dummy::ProjectAPI, type: :request do
156
156
 
157
157
  it "should return the project API's declared default paginated results" do
158
158
  get '/api/v1/projects'
159
- response.should be_success
159
+ response.should be_successful
160
160
  json.length.should == 2
161
161
  json.first['id'].should eq Project.all[2].id
162
162
  json.second['id'].should eq Project.all[3].id
@@ -164,17 +164,17 @@ describe Dummy::ProjectAPI, type: :request do
164
164
  end
165
165
 
166
166
  it "should return the request number of results" do
167
- get '/api/v1/projects', per_page: 9, offset: 9
168
- response.should be_success
167
+ get '/api/v1/projects', params: { per_page: 9, offset: 9 }
168
+ response.should be_successful
169
169
  json.size.should == 9
170
170
  json.map {|j| j['id']}.should eq Project.all[9..17].map(&:id)
171
171
  response.headers.slice("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "X-Offset").values.should eq ["20", "2", "9", "1", "2", "", "9"]
172
172
  end
173
173
 
174
174
  it "should respect the maximum number of results" do
175
- get '/api/v1/projects', per_page: 20, offset: 0
175
+ get '/api/v1/projects', params: { per_page: 20, offset: 0 }
176
176
  response.code.should eq "400"
177
- json['error'].should eq "per_page must be less than 10"
177
+ json['error'].should eq "per_page must be less than or equal 10"
178
178
  end
179
179
  end
180
180