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.
@@ -10,6 +10,10 @@ module Bearcat
10
10
  get("/api/v1/users/#{user.to_s}/avatars", params)
11
11
  end
12
12
 
13
+ def add_user(account, params={})
14
+ post("/api/v1/accounts/#{account.to_s}/users", params)
15
+ end
16
+
13
17
  end
14
18
  end
15
19
  end
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '0.9.2' unless defined?(Bearcat::VERSION)
2
+ VERSION = '0.9.3' unless defined?(Bearcat::VERSION)
3
3
  end
@@ -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
- it "returns all users for an account" do
9
- stub_get(@client, "/api/v1/accounts/1/users").to_return(json_response("account_users.json"))
10
- users = @client.list_users(1)
11
- users.count.should == 3
12
- users.last['id'].should == 3
13
- users.first['id'].should == 1
14
- users.first['name'].should == 'test user 1'
15
- end
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
- it "returns the possible user avatar options" do
26
- stub_get(@client, "/api/v1/users/1/avatars").to_return(json_response("user_avatars.json"))
27
- user_avatars = @client.user_avatars(1)
28
- user_avatars.count.should == 2
29
- user_avatars.first['type'].should == 'gravatar'
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
@@ -0,0 +1,8 @@
1
+ {
2
+ "id":10,
3
+ "name":"testuser",
4
+ "sortable_name":"testuser",
5
+ "short_name":"testuser",
6
+ "login_id":"testuser@testing.test",
7
+ "locale":null
8
+ }
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.2
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-11 00:00:00.000000000 Z
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