coalescing_panda 4.1.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ FactoryGirl.define do
2
+ factory :assignment_group, class: CoalescingPanda::AssignmentGroup do
3
+ name "test assignment group"
4
+ course
5
+ context_id '1'
6
+ context_type 'Course'
7
+ position '1'
8
+ group_weight 50.5
9
+ workflow_state 'active'
10
+ sequence :canvas_assignment_group_id do |n|
11
+ "#{n}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::AssignmentGroup, :type => :model do
4
+ let(:assignment_group) { FactoryGirl.create(:assignment_group) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a course' do
8
+ expect(CoalescingPanda::AssignmentGroup.reflect_on_association(:course)).to_not be_nil
9
+ expect(CoalescingPanda::AssignmentGroup.reflect_on_association(:course).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should have many assignments' do
13
+ expect(CoalescingPanda::AssignmentGroup.reflect_on_association(:assignments)).to_not be_nil
14
+ expect(CoalescingPanda::AssignmentGroup.reflect_on_association(:assignments).macro).to eql(:has_many)
15
+ end
16
+ end
17
+
18
+ context "validations" do
19
+ it "should require a canvas id" do
20
+ expect(FactoryGirl.build(:assignment_group, canvas_assignment_group_id: "")).to_not be_valid
21
+ end
22
+
23
+ it "should require a course" do
24
+ expect(FactoryGirl.build(:assignment_group, coalescing_panda_course_id: "")).to_not be_valid
25
+ end
26
+
27
+ it "should be valid with valid data" do
28
+ expect(FactoryGirl.build(:assignment_group)).to be_valid
29
+ end
30
+ end
31
+
32
+ end
@@ -7,6 +7,7 @@ RSpec.describe CoalescingPanda::Assignment, :type => :model do
7
7
  it 'should belong_to a course' do
8
8
  expect(CoalescingPanda::Assignment.reflect_on_association(:course)).to_not be_nil
9
9
  expect(CoalescingPanda::Assignment.reflect_on_association(:course).macro).to eql(:belongs_to)
10
+ expect(CoalescingPanda::Assignment.reflect_on_association(:assignment_group).macro).to eql(:belongs_to)
10
11
  end
11
12
 
12
13
  it 'should have many submisssions' do
@@ -43,6 +43,11 @@ RSpec.describe CoalescingPanda::Course, :type => :model do
43
43
  expect(CoalescingPanda::Course.reflect_on_association(:users)).to_not be_nil
44
44
  expect(CoalescingPanda::Course.reflect_on_association(:users).macro).to eql(:has_many)
45
45
  end
46
+
47
+ it 'should have many assignment groups' do
48
+ expect(CoalescingPanda::Course.reflect_on_association(:assignment_groups)).to_not be_nil
49
+ expect(CoalescingPanda::Course.reflect_on_association(:assignment_groups).macro).to eql(:has_many)
50
+ end
46
51
  end
47
52
 
48
53
  context "validations" do
@@ -2,7 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do
4
4
  let(:course) { FactoryGirl.create(:course) }
5
- let(:worker) { CoalescingPanda::Workers::CourseMiner.new(course, [:sections, :users, :enrollments, :assignments, :submissions, :groups, :group_memberships]) }
5
+ let(:worker) { CoalescingPanda::Workers::CourseMiner.new(course, [:sections, :users, :enrollments, :assignments, :assignment_groups, :submissions, :groups, :group_memberships]) }
6
6
  let(:users_response) {[
7
7
  {"id"=>1, "name"=>"teacher@test.com", "sortable_name"=>"teacher@test.com", "short_name"=>"teacher@test.com", "login_id"=>"teacher@test.com"},
8
8
  {"id"=>2, "name"=>"student1@test.com", "sortable_name"=>"student1@test.com", "short_name"=>"student1@test.com", "login_id"=>"student1@test.com"},
@@ -36,6 +36,9 @@ RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do
36
36
  {"group_id"=> 4, "id"=> 13, "moderator"=> false, "user_id"=> 2, "workflow_state"=> "accepted"},
37
37
  {"group_id"=> 4, "id"=> 14, "moderator"=> false, "user_id"=> 3, "workflow_state"=> "accepted"}
38
38
  ]}
39
+ let(:assignment_groups_response) {[
40
+ {"group_weight" => 500, "id" => 3, "name" => "Assignments", "position" => 3, "rules" => {} }
41
+ ]}
39
42
 
40
43
  before do
41
44
  Bearcat::Client.any_instance.stub(:list_course_users) { double(Bearcat::ApiArray, :all_pages! => users_response) }
@@ -47,13 +50,14 @@ RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do
47
50
  Bearcat::Client.any_instance.stub(:get_course_submissions).with("1", "2") { double(Bearcat::ApiArray, :all_pages! => submissions_response2) }
48
51
  Bearcat::Client.any_instance.stub(:course_groups) { double(Bearcat::ApiArray, :all_pages! => groups_response) }
49
52
  Bearcat::Client.any_instance.stub(:list_group_memberships) { double(Bearcat::ApiArray, :all_pages! => membership_response) }
53
+ Bearcat::Client.any_instance.stub(:list_assignment_groups) { double(Bearcat::ApiArray, :all_pages! => assignment_groups_response) }
50
54
  end
51
55
 
52
56
  describe '#initialize' do
53
57
  it 'should set instance variables a user' do
54
58
  expect(worker.course).to eq course
55
59
  expect(worker.account).to eq course.account
56
- expect(worker.options).to eq [:sections, :users, :enrollments, :assignments, :submissions, :groups, :group_memberships]
60
+ expect(worker.options).to eq [:sections, :users, :enrollments, :assignments, :assignment_groups, :submissions, :groups, :group_memberships]
57
61
  expect(worker.batch).to eq CoalescingPanda::CanvasBatch.last
58
62
  end
59
63
  end
@@ -99,6 +103,13 @@ RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do
99
103
  expect(CoalescingPanda::Assignment.count).to eq 2
100
104
  end
101
105
 
106
+ it 'creates assignment groups' do
107
+ CoalescingPanda::AssignmentGroup.destroy_all
108
+ expect(CoalescingPanda::AssignmentGroup.count).to eq 0
109
+ worker.sync_assignment_groups(assignment_groups_response)
110
+ expect(CoalescingPanda::AssignmentGroup.count).to eq 1
111
+ end
112
+
102
113
  it 'creates submissions' do
103
114
  CoalescingPanda::Submission.destroy_all
104
115
  submissions_response = submissions_response1 + submissions_response2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coalescing_panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Mills
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-04 00:00:00.000000000 Z
13
+ date: 2015-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -328,6 +328,7 @@ files:
328
328
  - app/controllers/coalescing_panda/oauth2_controller.rb
329
329
  - app/helpers/coalescing_panda/canvas_batches_helper.rb
330
330
  - app/models/coalescing_panda/assignment.rb
331
+ - app/models/coalescing_panda/assignment_group.rb
331
332
  - app/models/coalescing_panda/canvas_api_auth.rb
332
333
  - app/models/coalescing_panda/canvas_batch.rb
333
334
  - app/models/coalescing_panda/course.rb
@@ -371,6 +372,8 @@ files:
371
372
  - db/migrate/20150107205405_create_coalescing_panda_groups.rb
372
373
  - db/migrate/20150107205413_create_coalescing_panda_group_memberships.rb
373
374
  - db/migrate/20150210180516_add_context_to_canvas_batch.rb
375
+ - db/migrate/20150506183335_create_coalescing_panda_assignment_groups.rb
376
+ - db/migrate/20150506192717_add_assignment_group_id_to_assignments.rb
374
377
  - lib/coalescing_panda/controller_helpers.rb
375
378
  - lib/coalescing_panda/engine.rb
376
379
  - lib/coalescing_panda/route_helpers.rb
@@ -419,6 +422,7 @@ files:
419
422
  - spec/dummy/Rakefile
420
423
  - spec/dummy/README.rdoc
421
424
  - spec/factories/accounts.rb
425
+ - spec/factories/assignment_groups.rb
422
426
  - spec/factories/assignments.rb
423
427
  - spec/factories/canvas_batches.rb
424
428
  - spec/factories/courses.rb
@@ -427,6 +431,7 @@ files:
427
431
  - spec/factories/submissions.rb
428
432
  - spec/factories/terms.rb
429
433
  - spec/factories/users.rb
434
+ - spec/models/coalescing_panda/assignment_group_spec.rb
430
435
  - spec/models/coalescing_panda/assignment_spec.rb
431
436
  - spec/models/coalescing_panda/canvas_api_auth_spec.rb
432
437
  - spec/models/coalescing_panda/canvas_batch_spec.rb
@@ -508,6 +513,7 @@ test_files:
508
513
  - spec/dummy/Rakefile
509
514
  - spec/dummy/README.rdoc
510
515
  - spec/factories/accounts.rb
516
+ - spec/factories/assignment_groups.rb
511
517
  - spec/factories/assignments.rb
512
518
  - spec/factories/canvas_batches.rb
513
519
  - spec/factories/courses.rb
@@ -516,6 +522,7 @@ test_files:
516
522
  - spec/factories/submissions.rb
517
523
  - spec/factories/terms.rb
518
524
  - spec/factories/users.rb
525
+ - spec/models/coalescing_panda/assignment_group_spec.rb
519
526
  - spec/models/coalescing_panda/assignment_spec.rb
520
527
  - spec/models/coalescing_panda/canvas_api_auth_spec.rb
521
528
  - spec/models/coalescing_panda/canvas_batch_spec.rb