lessonly-ruby 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e099aac6272001aab6e3fffb631902017d72cb8e
4
- data.tar.gz: d106ee5bcf7f0615811b82e3fc4c6215c7be673d
3
+ metadata.gz: 4f284456492f751b0ebf56f2b5de8d04442d996b
4
+ data.tar.gz: 9ae71b4e6cb547b24132b1ecce901147c7d9e48b
5
5
  SHA512:
6
- metadata.gz: 9352ff867f38cbcaf5b27223909d6793b71d593178e9e6071984e6ea9bd6baec885a5ffc203fe115a2c0bc10ff91bc3bbcf7f167a82a4c8a344ce61838e13b95
7
- data.tar.gz: 5b6f37e8dd0a5e086ead5d8da592d49edaa6d282b5ee6ca4413350f0534df9e907f8450f64457f7ebba822f1e5277f0a40ff45675d84b28a6ec161cd802583e5
6
+ metadata.gz: d8f1d8bb820e0fad5ed01815527531cb0d5aff25827ac0e357db80511f981efac0eb9874824c70e85fdf79f1abf1410347ec3befd448eaedfc97a54587a27d09
7
+ data.tar.gz: a88f6c70015c417484def558ab730979b85eefb9912294d060d9149a7f8665c9e7f1ef924d6c5f6f2aa0f398fd1badd3bc5926e8fa3f4c026ac89ecf47557ca4
@@ -14,13 +14,17 @@ module Lessonly
14
14
  end
15
15
  end
16
16
 
17
- def create_assignment(user, due_by = 1.year.from_now)
18
- self.assignments = assignments.push(
17
+ def create_assignment(users, due_by = 1.year.from_now)
18
+ users = [users] unless users.is_a? Array
19
+
20
+ new_assignments = users.map do |user|
19
21
  Lessonly::Assignment.new(agent, assignee_id: user.id, due_by: due_by)
20
- )
22
+ end
23
+
24
+ self.assignments = assignments + new_assignments
21
25
 
22
26
  client.put "#{href}/assignments",
23
- Resource.new(agent, assignments: assignments)
27
+ Resource.new(agent, assignments: new_assignments)
24
28
  end
25
29
 
26
30
  def destroy_assignment(user)
@@ -1,3 +1,3 @@
1
1
  module Lessonly
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/spec/course_spec.rb CHANGED
@@ -53,6 +53,18 @@ describe Lessonly::Course do
53
53
  expect(course.assignments.map(&:assignee_id)).to include(user.id)
54
54
  expect(course.assignments.count).to eq 2
55
55
  end
56
+
57
+ it 'should accept multiple users' do
58
+ course = Lessonly::Course.find(1)
59
+ user3 = Lessonly::User.find(3)
60
+ user2 = Lessonly::User.find(2)
61
+
62
+ course.create_assignment([user3, user2])
63
+
64
+ expect(course.assignments.map(&:assignee_id)).to include(user3.id)
65
+ expect(course.assignments.map(&:assignee_id)).to include(user2.id)
66
+ expect(course.assignments.count).to eq 3
67
+ end
56
68
  end
57
69
 
58
70
  describe '#destroy_assignment' do
@@ -0,0 +1,8 @@
1
+ {
2
+ "type": "user",
3
+ "id": 2,
4
+ "email": "skylar@aptible.com",
5
+ "name": "Skylar Anderson",
6
+ "role": "admin",
7
+ "custom_user_field_data": [ ]
8
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lessonly-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skylar Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -190,6 +190,7 @@ files:
190
190
  - spec/support/fixtures/get_groups_1.json
191
191
  - spec/support/fixtures/get_users.json
192
192
  - spec/support/fixtures/get_users_1.json
193
+ - spec/support/fixtures/get_users_2.json
193
194
  - spec/support/fixtures/get_users_3.json
194
195
  - spec/support/fixtures/put_courses_1_assignments.json
195
196
  - spec/support/fixtures/put_groups_1.json
@@ -230,6 +231,7 @@ test_files:
230
231
  - spec/support/fixtures/get_groups_1.json
231
232
  - spec/support/fixtures/get_users.json
232
233
  - spec/support/fixtures/get_users_1.json
234
+ - spec/support/fixtures/get_users_2.json
233
235
  - spec/support/fixtures/get_users_3.json
234
236
  - spec/support/fixtures/put_courses_1_assignments.json
235
237
  - spec/support/fixtures/put_groups_1.json