introspective_grape 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +16 -3
- data/CHANGELOG.md +16 -8
- data/README.md +6 -6
- data/gemfiles/2.0.0-Gemfile +1 -1
- data/gemfiles/Gemfile.rails.3.2.22 +1 -1
- data/gemfiles/Gemfile.rails.4.1.13 +1 -1
- data/gemfiles/Gemfile.rails.4.2.7.1 +1 -1
- data/gemfiles/Gemfile.rails.4.2.7.1.new.swagger +1 -1
- data/gemfiles/Gemfile.rails.4.2.8 +1 -1
- data/gemfiles/Gemfile.rails.5.0.1 +1 -1
- data/gemfiles/Gemfile.rails.master +1 -1
- data/introspective_grape.gemspec +2 -2
- data/lib/introspective_grape/api.rb +16 -16
- data/lib/introspective_grape/camel_snake.rb +5 -4
- data/lib/introspective_grape/filters.rb +2 -2
- data/lib/introspective_grape/formatter/camel_json.rb +12 -9
- data/lib/introspective_grape/helpers.rb +3 -3
- data/lib/introspective_grape/snake_params.rb +2 -1
- data/lib/introspective_grape/traversal.rb +5 -5
- data/lib/introspective_grape/validators.rb +1 -1
- data/lib/introspective_grape/version.rb +1 -1
- data/spec/dummy/app/api/dummy/chat_api.rb +4 -4
- data/spec/dummy/app/api/dummy/company_api.rb +1 -1
- data/spec/dummy/app/api/dummy/location_api.rb +2 -2
- data/spec/dummy/app/api/dummy/project_api.rb +1 -1
- data/spec/dummy/app/api/dummy/sessions.rb +3 -3
- data/spec/dummy/app/api/dummy/user_api.rb +1 -1
- data/spec/dummy/app/api/dummy_api.rb +0 -3
- data/spec/dummy/app/api/error_handlers.rb +2 -2
- data/spec/dummy/app/models/admin_user.rb +1 -1
- data/spec/dummy/app/models/chat.rb +1 -1
- data/spec/dummy/app/models/chat_message.rb +1 -1
- data/spec/dummy/app/models/chat_user.rb +1 -1
- data/spec/dummy/app/models/company.rb +1 -1
- data/spec/dummy/app/models/image.rb +1 -1
- data/spec/dummy/app/models/project.rb +1 -1
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/app/models/user/chatter.rb +4 -4
- data/spec/dummy/app/models/user_location.rb +4 -4
- data/spec/dummy/app/policies/location_policy.rb +1 -1
- data/spec/dummy/app/policies/project_policy.rb +5 -5
- data/spec/dummy/app/policies/role_policy.rb +2 -2
- data/spec/dummy/app/policies/user_policy.rb +1 -1
- data/spec/dummy/db/migrate/20150414213154_add_user_authentication_token.rb +1 -1
- data/spec/dummy/db/migrate/20150601212924_create_location_beacons.rb +1 -1
- data/spec/dummy/db/migrate/20150616205336_add_role_user_constraint.rb +1 -1
- data/spec/dummy/db/migrate/20150727214950_add_confirmable_to_devise.rb +1 -1
- data/spec/dummy/db/migrate/20150820190524_add_user_names.rb +2 -2
- data/spec/models/project_spec.rb +3 -3
- data/spec/models/role_spec.rb +6 -6
- data/spec/models/team_spec.rb +2 -2
- data/spec/models/team_user_spec.rb +4 -4
- data/spec/models/user_location_spec.rb +1 -1
- data/spec/models/user_project_job_spec.rb +2 -2
- data/spec/models/user_spec.rb +10 -10
- data/spec/requests/chat_api_spec.rb +7 -7
- data/spec/requests/company_api_spec.rb +4 -4
- data/spec/requests/location_api_spec.rb +10 -10
- data/spec/requests/project_api_spec.rb +18 -18
- data/spec/requests/role_api_spec.rb +1 -1
- data/spec/requests/sessions_api_spec.rb +3 -3
- data/spec/requests/swagger_spec.rb +1 -1
- data/spec/requests/user_api_spec.rb +13 -13
- data/spec/support/blueprints.rb +10 -10
- data/spec/support/location_helper.rb +6 -6
- data/spec/support/request_helpers.rb +4 -3
- metadata +6 -10
- data/lib/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/dummy/app/api/.DS_Store +0 -0
data/spec/models/role_spec.rb
CHANGED
@@ -3,10 +3,10 @@ require 'rails_helper'
|
|
3
3
|
RSpec.describe Role, type: :model do
|
4
4
|
before :all do
|
5
5
|
end
|
6
|
-
let(:user) { User.make! }
|
7
|
-
let(:company) { Company.make! }
|
8
|
-
let(:project) { Project.make! }
|
9
|
-
|
6
|
+
let(:user) { User.make! }
|
7
|
+
let(:company) { Company.make! }
|
8
|
+
let(:project) { Project.make! }
|
9
|
+
|
10
10
|
it "allows user assignment to company admin" do
|
11
11
|
ur = Role.create(user:user, ownable: company)
|
12
12
|
ur.valid?.should be_truthy
|
@@ -17,7 +17,7 @@ RSpec.describe Role, type: :model do
|
|
17
17
|
ur.valid?.should be_falsey
|
18
18
|
end
|
19
19
|
|
20
|
-
context "User helper methods" do
|
20
|
+
context "User helper methods" do
|
21
21
|
it "should register a user as a super user" do
|
22
22
|
user.superuser?.should == false
|
23
23
|
user.superuser = true
|
@@ -31,7 +31,7 @@ RSpec.describe Role, type: :model do
|
|
31
31
|
user.admin?(company).should == true
|
32
32
|
end
|
33
33
|
|
34
|
-
it "should register a project administrator" do
|
34
|
+
it "should register a project administrator" do
|
35
35
|
user.admin?(project).should == false
|
36
36
|
Role.create!(user:user, ownable: project)
|
37
37
|
user.reload
|
data/spec/models/team_spec.rb
CHANGED
@@ -6,11 +6,11 @@ RSpec.describe Team, type: :model do
|
|
6
6
|
Team.make.valid?.should == true
|
7
7
|
end
|
8
8
|
|
9
|
-
it "should save a valid instance" do
|
9
|
+
it "should save a valid instance" do
|
10
10
|
Team.make!.should == Team.last
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should be created by a user" do
|
13
|
+
it "should be created by a user" do
|
14
14
|
Team.make.creator.kind_of?(User).should == true
|
15
15
|
end
|
16
16
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe TeamUser, type: :model do
|
4
|
-
|
4
|
+
|
5
5
|
it "should make a valid instance" do
|
6
6
|
TeamUser.make.valid?.should == true
|
7
7
|
end
|
8
8
|
|
9
|
-
it "should save a valid instance" do
|
9
|
+
it "should save a valid instance" do
|
10
10
|
TeamUser.make!.should == TeamUser.last
|
11
11
|
end
|
12
12
|
|
13
|
-
it "should validate the user belongs to the project" do
|
14
|
-
t = TeamUser.make(team: Team.make!, user: User.make!)
|
13
|
+
it "should validate the user belongs to the project" do
|
14
|
+
t = TeamUser.make(team: Team.make!, user: User.make!)
|
15
15
|
t.valid?.should == false
|
16
16
|
t.errors.messages[:user].first.should =~ /is not on the \w+ project/
|
17
17
|
end
|
@@ -8,7 +8,7 @@ RSpec.describe UserLocation, type: :model do
|
|
8
8
|
|
9
9
|
let(:user) { User.make! }
|
10
10
|
|
11
|
-
it "validates the detectable type" do
|
11
|
+
it "validates the detectable type" do
|
12
12
|
ul = UserLocation.new(user: user, location: Location.last, detectable: Location.last, coords: rand_coords)
|
13
13
|
ul.valid?.should == false
|
14
14
|
ul.errors[:detectable_type].should == ["is not included in the list"]
|
@@ -14,7 +14,7 @@ RSpec.describe UserProjectJob, type: :model do
|
|
14
14
|
UserProjectJob.make.title.should_not == nil
|
15
15
|
end
|
16
16
|
|
17
|
-
it "should scope job options by project" do
|
17
|
+
it "should scope job options by project" do
|
18
18
|
ProjectJob.make!
|
19
19
|
ProjectJob.make!
|
20
20
|
|
@@ -22,7 +22,7 @@ RSpec.describe UserProjectJob, type: :model do
|
|
22
22
|
j = Job.make!
|
23
23
|
p.jobs.push j
|
24
24
|
p.save
|
25
|
-
UserProjectJob.make!(project: p, job: j)
|
25
|
+
UserProjectJob.make!(project: p, job: j)
|
26
26
|
UserProjectJob.options_for_job(p).should == p.jobs
|
27
27
|
end
|
28
28
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -2,24 +2,24 @@ require 'rails_helper'
|
|
2
2
|
include ActionDispatch::TestProcess # -> fixture_file_upload
|
3
3
|
|
4
4
|
RSpec.describe User, type: :model do
|
5
|
-
context 'User::Chatter' do
|
5
|
+
context 'User::Chatter' do
|
6
6
|
|
7
7
|
def user(email)
|
8
|
-
User.find_by_email(email) || User.make!(email: email)
|
8
|
+
User.find_by_email(email) || User.make!(email: email)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "uploads an avatar to AWS" do
|
11
|
+
it "uploads an avatar to AWS" do
|
12
12
|
u = User.make
|
13
13
|
u.avatar = Image.new(file: fixture_file_upload( Rails.root+'../fixtures/images/exif.jpeg'))
|
14
14
|
u.save
|
15
15
|
u.avatar.file_processing?.should == false
|
16
|
-
|
16
|
+
|
17
17
|
#u.avatar_url.should =~ /medium\/exif.jpeg/
|
18
18
|
#u.avatar_url(:original).should =~ /original\/exif.jpeg/
|
19
19
|
#u.avatar_url(:thumb).should =~ /thumb\/exif.jpeg/
|
20
20
|
end
|
21
21
|
|
22
|
-
context "chatting" do
|
22
|
+
context "chatting" do
|
23
23
|
let(:sender) { user('sender@springshot.com') }
|
24
24
|
let(:target) { user('target1@springshot.com') }
|
25
25
|
let(:target2) { user('target2@springshot.com') }
|
@@ -28,20 +28,20 @@ RSpec.describe User, type: :model do
|
|
28
28
|
let(:discussion) {
|
29
29
|
c = sender.chat([target,target2], 'Hey guys')
|
30
30
|
target2.reply( c, "What's up?")
|
31
|
-
c
|
31
|
+
c
|
32
32
|
}
|
33
33
|
|
34
34
|
|
35
|
-
before :all do
|
35
|
+
before :all do
|
36
36
|
Chat.destroy_all
|
37
37
|
end
|
38
38
|
|
39
|
-
it "chatting a user returns a chat" do
|
39
|
+
it "chatting a user returns a chat" do
|
40
40
|
c = sender.chat(target, 'a private message')
|
41
41
|
c.kind_of?(Chat).should be_truthy
|
42
42
|
end
|
43
43
|
|
44
|
-
it "a user sees that she has new messages in a discussion" do
|
44
|
+
it "a user sees that she has new messages in a discussion" do
|
45
45
|
discussion.save! # invoke create hooks on ChatMessage for ChatMessageUser
|
46
46
|
sender.new_messages?(discussion)[discussion.id].should == 1
|
47
47
|
target2.new_messages?(discussion)[discussion.id].should == 0
|
@@ -57,7 +57,7 @@ RSpec.describe User, type: :model do
|
|
57
57
|
target2.new_messages?[chat2.id].should == 2
|
58
58
|
end
|
59
59
|
|
60
|
-
it "a user sees her new messages" do
|
60
|
+
it "a user sees her new messages" do
|
61
61
|
discussion.save!
|
62
62
|
|
63
63
|
sender.read_messages.size.should == 1
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
describe Dummy::ChatAPI, type: :request do
|
3
3
|
|
4
|
-
before :all do
|
4
|
+
before :all do
|
5
5
|
User.destroy_all
|
6
6
|
@without_authentication = true
|
7
7
|
|
@@ -23,7 +23,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
23
23
|
context "while current_user is the current user" do
|
24
24
|
|
25
25
|
before :each do
|
26
|
-
@chat.reload
|
26
|
+
@chat.reload
|
27
27
|
Grape::Endpoint.before_each do |endpoint|
|
28
28
|
allow(endpoint).to receive(:current_user) { @current_user }
|
29
29
|
end
|
@@ -58,7 +58,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context :messages do
|
61
|
+
context :messages do
|
62
62
|
|
63
63
|
it "should get no new chat messages if user was last to reply" do
|
64
64
|
get "/api/v1/chats/messages", id: @chat.id, new: true
|
@@ -73,7 +73,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
73
73
|
json.size.should == 1
|
74
74
|
end
|
75
75
|
|
76
|
-
it "should mark all new messages from all chats as read if mark_as_read is true" do
|
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
79
|
get "/api/v1/chats/messages", new: true, mark_as_read: true
|
@@ -84,7 +84,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
84
84
|
end
|
85
85
|
|
86
86
|
|
87
|
-
context :users do
|
87
|
+
context :users do
|
88
88
|
it "should list the users in a chat" do
|
89
89
|
get "/api/v1/chats/users", id: @chat.id
|
90
90
|
response.should be_success
|
@@ -126,7 +126,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
126
126
|
|
127
127
|
it "should raise an error when an outsider tries to add themselves to a chat" do
|
128
128
|
post "/api/v1/chats/users", id: @lurk.id, user_ids: @current_user.id
|
129
|
-
response.status.should == 400
|
129
|
+
response.status.should == 400
|
130
130
|
json['error'].should == 'Only current chat participants can add users.'
|
131
131
|
@lurk.reload
|
132
132
|
@lurk.active_users.include?(@current_user).should == false
|
@@ -160,7 +160,7 @@ describe Dummy::ChatAPI, type: :request do
|
|
160
160
|
@chat.active_users.include?(@current_user).should == false
|
161
161
|
end
|
162
162
|
|
163
|
-
it "should only allow chat participants to reply" do
|
163
|
+
it "should only allow chat participants to reply" do
|
164
164
|
@current_user.leave_chat(@chat)
|
165
165
|
@current_user.reload
|
166
166
|
put "/api/v1/chats/#{@chat.id}", message: "I'm an interloper"
|
@@ -55,12 +55,12 @@ 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' }
|
58
|
+
post "/api/v1/companies", { name: 'Test 123', short_name: 'T123' }
|
59
59
|
response.should be_success
|
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
65
|
post "/api/v1/companies", { name: 'a'*257, short_name: 'a'*11 }
|
66
66
|
response.code.should == "400"
|
@@ -70,7 +70,7 @@ 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 }
|
73
|
+
put "/api/v1/companies/#{company.id}", { name: new_name }
|
74
74
|
response.should be_success
|
75
75
|
company.reload
|
76
76
|
company.name.should == new_name
|
@@ -88,7 +88,7 @@ describe Dummy::CompanyAPI, type: :request do
|
|
88
88
|
|
89
89
|
it "should validate json parameters" do
|
90
90
|
put "/api/v1/companies/#{company.id}", { gizmos: "garbage" }
|
91
|
-
json["error"].should eq "gizmos must be valid JSON!"
|
91
|
+
json["error"].should eq "gizmos must be valid JSON!"
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should validate json array parameters" do
|
@@ -7,7 +7,7 @@ describe Dummy::LocationAPI, type: :request do
|
|
7
7
|
|
8
8
|
before :all do
|
9
9
|
create_test_airport
|
10
|
-
Location.make!(name: "TEST2", kind: "airport")
|
10
|
+
Location.make!(name: "TEST2", kind: "airport")
|
11
11
|
end
|
12
12
|
|
13
13
|
|
@@ -32,7 +32,7 @@ describe Dummy::LocationAPI, type: :request do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
|
-
it "should generate basic filters on the whitelisted model attributes" do
|
35
|
+
it "should generate basic filters on the whitelisted model attributes" do
|
36
36
|
get '/api/v1/locations', { name: "TEST" }
|
37
37
|
response.should be_success
|
38
38
|
json.length.should eq 1
|
@@ -40,7 +40,7 @@ describe Dummy::LocationAPI, type: :request do
|
|
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\"}}"
|
43
|
+
get '/api/v1/locations', filter: "{\"child_locations_locations\":{\"name\":\"Terminal A\"}}"
|
44
44
|
response.should be_success
|
45
45
|
json.length.should eq 1
|
46
46
|
json.first['child_locations'].length.should eq 1
|
@@ -59,14 +59,14 @@ 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" }
|
62
|
+
post "/api/v1/locations", { name: 'Test 123', kind: "terminal" }
|
63
63
|
response.should be_success
|
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 ] }
|
69
|
+
post "/api/v1/locations", { name: 'Test 123', kind: "gate", beacons_attributes: [ b.attributes ] }
|
70
70
|
response.should be_success
|
71
71
|
json['name'].should == "Test 123"
|
72
72
|
l = Location.find(json['id'])
|
@@ -75,10 +75,10 @@ describe Dummy::LocationAPI, type: :request do
|
|
75
75
|
created.minor.should == b.minor
|
76
76
|
created.major.should == b.major
|
77
77
|
end
|
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 }
|
81
|
+
post "/api/v1/locations", { name: 'Test 123', kind: "airport", gps_attributes: gps.attributes }
|
82
82
|
response.should be_success
|
83
83
|
json['name'].should == "Test 123"
|
84
84
|
l = Location.find(json['id'])
|
@@ -88,7 +88,7 @@ describe Dummy::LocationAPI, type: :request do
|
|
88
88
|
created.lng.round(10).should == gps.lng.round(10)
|
89
89
|
created.alt.should == gps.alt
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
it "should validate a new location" do
|
93
93
|
post "/api/v1/locations", { name: 'test' }
|
94
94
|
response.code.should == "400"
|
@@ -97,7 +97,7 @@ describe Dummy::LocationAPI, type: :request do
|
|
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 }
|
100
|
+
put "/api/v1/locations/#{location.id}", { name: new_name }
|
101
101
|
response.should be_success
|
102
102
|
location.reload
|
103
103
|
location.name.should == new_name
|
@@ -14,9 +14,9 @@ describe Dummy::ProjectAPI, type: :request do
|
|
14
14
|
|
15
15
|
cm.admin_companies.push c
|
16
16
|
pm.admin_projects.push p
|
17
|
-
|
17
|
+
|
18
18
|
cm.save!
|
19
|
-
pm.save!
|
19
|
+
pm.save!
|
20
20
|
end
|
21
21
|
|
22
22
|
let(:company) { Company.find_by_name("Sprockets") }
|
@@ -41,7 +41,7 @@ describe Dummy::ProjectAPI, type: :request do
|
|
41
41
|
response.code.should == "404"
|
42
42
|
end
|
43
43
|
|
44
|
-
context "edit a project team" do
|
44
|
+
context "edit a project team" do
|
45
45
|
|
46
46
|
before(:each) do
|
47
47
|
@team = Team.make!(project: project)
|
@@ -51,8 +51,8 @@ describe Dummy::ProjectAPI, type: :request do
|
|
51
51
|
UserProjectJob.make!(project: project, job: project.jobs.first, user: @u2)
|
52
52
|
end
|
53
53
|
|
54
|
-
context "via nested attributes" do
|
55
|
-
it "should create a team with users" do
|
54
|
+
context "via nested attributes" do
|
55
|
+
it "should create a team with users" do
|
56
56
|
p = {
|
57
57
|
name: 'New Team', team_users_attributes: [{ user_id: @u1.id }, { user_id: @u2.id }]
|
58
58
|
}
|
@@ -62,9 +62,9 @@ describe Dummy::ProjectAPI, type: :request do
|
|
62
62
|
Team.last.users.to_a.should == [@u1,@u2]
|
63
63
|
end
|
64
64
|
|
65
|
-
it "should add a team member" do
|
65
|
+
it "should add a team member" do
|
66
66
|
p = { team_users_attributes: [
|
67
|
-
{ user_id: @u1.id }, { user_id: @u2.id }
|
67
|
+
{ user_id: @u1.id }, { user_id: @u2.id }
|
68
68
|
] }
|
69
69
|
put "/api/v1/projects/#{project.id}/teams/#{@team.id}", p
|
70
70
|
response.should be_success
|
@@ -72,11 +72,11 @@ describe Dummy::ProjectAPI, type: :request do
|
|
72
72
|
Team.last.users.to_a.should == [@u1,@u2]
|
73
73
|
end
|
74
74
|
|
75
|
-
it "should delete a team member" do
|
75
|
+
it "should delete a team member" do
|
76
76
|
@team.users << [@u1,@u2]
|
77
77
|
@team.save!
|
78
78
|
p = { team_users_attributes: [
|
79
|
-
{ id: @team.team_users.where(user_id:@u1.id).first.id, _destroy: 1 }
|
79
|
+
{ id: @team.team_users.where(user_id:@u1.id).first.id, _destroy: 1 }
|
80
80
|
] }
|
81
81
|
put "/api/v1/projects/#{project.id}/teams/#{@team.id}", p
|
82
82
|
response.should be_success
|
@@ -84,15 +84,15 @@ describe Dummy::ProjectAPI, type: :request do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
context "edit a project team via nested routes" do
|
88
|
-
it "should add a team member" do
|
87
|
+
context "edit a project team via nested routes" do
|
88
|
+
it "should add a team member" do
|
89
89
|
p = { user_id: @u1.id }
|
90
90
|
post "/api/v1/projects/#{project.id}/teams/#{@team.id}/team_users", p
|
91
91
|
response.should be_success
|
92
92
|
Team.last.users.to_a.should == [@u1]
|
93
93
|
end
|
94
94
|
|
95
|
-
it "should delete a team member" do
|
95
|
+
it "should delete a team member" do
|
96
96
|
@team.users << [@u1,@u2]
|
97
97
|
@team.save!
|
98
98
|
id = @team.team_users.where(user_id:@u1.id).first.id
|
@@ -105,14 +105,14 @@ describe Dummy::ProjectAPI, type: :request do
|
|
105
105
|
end
|
106
106
|
|
107
107
|
context "As a company admin" do
|
108
|
-
before :all do
|
108
|
+
before :all do
|
109
109
|
@without_authentication = true
|
110
110
|
end
|
111
111
|
|
112
112
|
before :each do
|
113
113
|
Grape::Endpoint.before_each do |endpoint|
|
114
114
|
allow(endpoint).to receive(:current_user) do
|
115
|
-
User.find_by_email("company.admin@springshot.com")
|
115
|
+
User.find_by_email("company.admin@springshot.com")
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -120,7 +120,7 @@ describe Dummy::ProjectAPI, type: :request do
|
|
120
120
|
it "should return a list of all the company's projects" do
|
121
121
|
get '/api/v1/projects', offset: 0
|
122
122
|
response.should be_success
|
123
|
-
json.length.should == 2
|
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
|
126
126
|
end
|
@@ -128,13 +128,13 @@ describe Dummy::ProjectAPI, type: :request do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
context "As a project admin" do
|
131
|
-
before :all do
|
131
|
+
before :all do
|
132
132
|
@without_authentication = true
|
133
133
|
end
|
134
134
|
before :each do
|
135
135
|
Grape::Endpoint.before_each do |endpoint|
|
136
136
|
allow(endpoint).to receive(:current_user) do
|
137
|
-
User.find_by_email("project.admin@springshot.com")
|
137
|
+
User.find_by_email("project.admin@springshot.com")
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -142,7 +142,7 @@ describe Dummy::ProjectAPI, type: :request do
|
|
142
142
|
it "should return a list of all the project admin's projects" do
|
143
143
|
get '/api/v1/projects', offset: 0
|
144
144
|
response.should be_success
|
145
|
-
json.length.should == 1
|
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
|
148
148
|
end
|