bearcat 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ require 'bearcat/client/sections'
9
9
  require 'bearcat/client/o_auth2'
10
10
  require 'bearcat/client/groups'
11
11
  require 'bearcat/client/conferences'
12
+ require 'bearcat/client/users'
12
13
 
13
14
  module Bearcat
14
15
  class Client < Footrest::Client
@@ -22,6 +23,7 @@ module Bearcat
22
23
  include OAuth2
23
24
  include Groups
24
25
  include Conferences
26
+ include Users
25
27
 
26
28
 
27
29
  # Override Footrest request for ApiArray support
@@ -0,0 +1,11 @@
1
+ module Bearcat
2
+ class Client < Footrest::Client
3
+ module Users
4
+
5
+ def list_users(account, params={})
6
+ get("/api/v1/accounts/#{account.to_s}/users", params)
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module Bearcat
2
- VERSION = '0.7' unless defined?(Bearcat::VERSION)
2
+ VERSION = '0.8' unless defined?(Bearcat::VERSION)
3
3
  end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ describe Bearcat::Client::Users do
4
+ before do
5
+ @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
6
+ end
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
16
+
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
+ end
24
+
25
+ end
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "name": "test user 1",
5
+ "sortable_name": "user 1, test",
6
+ "short_name": "test user 1",
7
+ "sis_user_id": "testusersisid1",
8
+ "sis_login_id": "testuser1",
9
+ "login_id": "testuser1"
10
+ }
11
+ ]
@@ -0,0 +1,29 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "name": "test user 1",
5
+ "sortable_name": "user 1, test",
6
+ "short_name": "test user 1",
7
+ "sis_user_id": "testusersisid1",
8
+ "sis_login_id": "testuser1",
9
+ "login_id": "testuser1"
10
+ },
11
+ {
12
+ "id": 2,
13
+ "name": "test user 2",
14
+ "sortable_name": "user 2, test",
15
+ "short_name": "test user 2",
16
+ "sis_user_id": "testusersisid2",
17
+ "sis_login_id": "testuser2",
18
+ "login_id": "testuser2"
19
+ },
20
+ {
21
+ "id": 3,
22
+ "name": "test user 3",
23
+ "sortable_name": "user 3, test",
24
+ "short_name": "test user 3",
25
+ "sis_user_id": "testusersisid3",
26
+ "sis_login_id": "testuser3",
27
+ "login_id": "testuser3"
28
+ }
29
+ ]
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.7'
4
+ version: '0.8'
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-01-14 00:00:00.000000000 Z
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -126,6 +126,7 @@ files:
126
126
  - lib/bearcat/client/outcome_groups.rb
127
127
  - lib/bearcat/client/outcomes.rb
128
128
  - lib/bearcat/client/sections.rb
129
+ - lib/bearcat/client/users.rb
129
130
  - lib/bearcat/client.rb
130
131
  - lib/bearcat/version.rb
131
132
  - lib/bearcat.rb
@@ -138,8 +139,11 @@ files:
138
139
  - spec/bearcat/client/outcome_groups_spec.rb
139
140
  - spec/bearcat/client/outcomes_spec.rb
140
141
  - spec/bearcat/client/sections_spec.rb
142
+ - spec/bearcat/client/users_spec.rb
141
143
  - spec/bearcat/client_spec.rb
142
144
  - spec/bearcat_spec.rb
145
+ - spec/fixtures/account_user.json
146
+ - spec/fixtures/account_users.json
143
147
  - spec/fixtures/assignment_section_override.json
144
148
  - spec/fixtures/assignments.json
145
149
  - spec/fixtures/conclude_enrollment.json
@@ -204,8 +208,11 @@ test_files:
204
208
  - spec/bearcat/client/outcome_groups_spec.rb
205
209
  - spec/bearcat/client/outcomes_spec.rb
206
210
  - spec/bearcat/client/sections_spec.rb
211
+ - spec/bearcat/client/users_spec.rb
207
212
  - spec/bearcat/client_spec.rb
208
213
  - spec/bearcat_spec.rb
214
+ - spec/fixtures/account_user.json
215
+ - spec/fixtures/account_users.json
209
216
  - spec/fixtures/assignment_section_override.json
210
217
  - spec/fixtures/assignments.json
211
218
  - spec/fixtures/conclude_enrollment.json