bearcat 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/bearcat/client/users.rb +4 -0
- data/lib/bearcat/version.rb +1 -1
- data/spec/bearcat/client/users_spec.rb +38 -20
- data/spec/fixtures/add_user.json +8 -0
- metadata +4 -2
data/lib/bearcat/client/users.rb
CHANGED
data/lib/bearcat/version.rb
CHANGED
@@ -5,28 +5,46 @@ describe Bearcat::Client::Users do
|
|
5
5
|
@client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
users
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
context 'GET' do
|
9
|
+
|
10
|
+
it "returns all users for an account" do
|
11
|
+
stub_get(@client, "/api/v1/accounts/1/users").to_return(json_response("account_users.json"))
|
12
|
+
users = @client.list_users(1)
|
13
|
+
users.count.should == 3
|
14
|
+
users.last['id'].should == 3
|
15
|
+
users.first['id'].should == 1
|
16
|
+
users.first['name'].should == 'test user 1'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "returns a user in an account if a search term is provided" do
|
20
|
+
stub_get(@client, "/api/v1/accounts/1/users?search_term=testusersisid1").to_return(json_response("account_user.json"))
|
21
|
+
user = @client.list_users(1, {"search_term" => "testusersisid1"})
|
22
|
+
user.count.should == 1
|
23
|
+
user.first['name'].should == 'test user 1'
|
24
|
+
user.first['sis_user_id'].should == 'testusersisid1'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns the possible user avatar options" do
|
28
|
+
stub_get(@client, "/api/v1/users/1/avatars").to_return(json_response("user_avatars.json"))
|
29
|
+
user_avatars = @client.user_avatars(1)
|
30
|
+
user_avatars.count.should == 2
|
31
|
+
user_avatars.first['type'].should == 'gravatar'
|
32
|
+
end
|
16
33
|
|
17
|
-
it "returns a user in an account if a search term is provided" do
|
18
|
-
stub_get(@client, "/api/v1/accounts/1/users?search_term=testusersisid1").to_return(json_response("account_user.json"))
|
19
|
-
user = @client.list_users(1, {"search_term" => "testusersisid1"})
|
20
|
-
user.count.should == 1
|
21
|
-
user.first['name'].should == 'test user 1'
|
22
|
-
user.first['sis_user_id'].should == 'testusersisid1'
|
23
34
|
end
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
36
|
+
context 'POST' do
|
37
|
+
|
38
|
+
it "creates a user in an account" do
|
39
|
+
pseudonym = "testuser@testing.test"
|
40
|
+
name = "testuser"
|
41
|
+
body = {"user" => {"name" => name}, "pseudonym" => {"unique_id" => pseudonym}}
|
42
|
+
stub_post(@client, "/api/v1/accounts/1/users").with(body: body).to_return(json_response("add_user.json"))
|
43
|
+
user = @client.add_user(1, body)
|
44
|
+
user['login_id'].should == pseudonym
|
45
|
+
user['name'].should == name
|
46
|
+
end
|
47
|
+
|
30
48
|
end
|
31
49
|
|
32
|
-
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bearcat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- spec/bearcat_spec.rb
|
149
149
|
- spec/fixtures/account_user.json
|
150
150
|
- spec/fixtures/account_users.json
|
151
|
+
- spec/fixtures/add_user.json
|
151
152
|
- spec/fixtures/assignment_section_override.json
|
152
153
|
- spec/fixtures/assignments.json
|
153
154
|
- spec/fixtures/conclude_enrollment.json
|
@@ -225,6 +226,7 @@ test_files:
|
|
225
226
|
- spec/bearcat_spec.rb
|
226
227
|
- spec/fixtures/account_user.json
|
227
228
|
- spec/fixtures/account_users.json
|
229
|
+
- spec/fixtures/add_user.json
|
228
230
|
- spec/fixtures/assignment_section_override.json
|
229
231
|
- spec/fixtures/assignments.json
|
230
232
|
- spec/fixtures/conclude_enrollment.json
|