coalescing_panda 3.2.3 → 4.0.0
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.
- checksums.yaml +4 -4
 - data/app/models/coalescing_panda/assignment.rb +1 -1
 - data/app/models/coalescing_panda/course.rb +7 -7
 - data/app/models/coalescing_panda/group.rb +1 -1
 - data/app/models/coalescing_panda/section.rb +1 -1
 - data/app/models/coalescing_panda/user.rb +2 -2
 - data/app/models/coalescing_panda/workers/course_miner.rb +112 -68
 - data/lib/coalescing_panda/version.rb +1 -1
 - data/spec/controllers/coalescing_panda/lti_controller_spec.rb +2 -7
 - data/spec/controllers/coalescing_panda/oauth2_controller_spec.rb +5 -3
 - data/spec/dummy/db/schema.rb +30 -49
 - data/spec/dummy/db/test.sqlite3 +0 -0
 - data/spec/dummy/log/test.log +33040 -0
 - data/spec/models/coalescing_panda/workers/course_miner_spec.rb +13 -77
 - metadata +2 -2
 
| 
         @@ -71,68 +71,54 @@ RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do 
     | 
|
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
     | 
    
         
            -
              describe '#api_method' do
         
     | 
| 
       75 
     | 
    
         
            -
                it 'returns the correct api method' do
         
     | 
| 
       76 
     | 
    
         
            -
                  expect(worker.api_method(:users)).to eq :list_course_users
         
     | 
| 
       77 
     | 
    
         
            -
                  expect(worker.api_method(:sections)).to eq :course_sections
         
     | 
| 
       78 
     | 
    
         
            -
                  expect(worker.api_method(:enrollments)).to eq :course_enrollments
         
     | 
| 
       79 
     | 
    
         
            -
                  expect(worker.api_method(:assignments)).to eq :assignments
         
     | 
| 
       80 
     | 
    
         
            -
                  expect(worker.api_method(:submissions)).to eq :get_course_submissions
         
     | 
| 
       81 
     | 
    
         
            -
                  expect(worker.api_method(:groups)).to eq :course_groups
         
     | 
| 
       82 
     | 
    
         
            -
                  expect(worker.api_method(:group_memberships)).to eq :list_group_memberships
         
     | 
| 
       83 
     | 
    
         
            -
                end
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                it 'raises and error if method doesnt exist' do
         
     | 
| 
       86 
     | 
    
         
            -
                  expect{ worker.api_method(:not_a_real_method) }.to raise_error
         
     | 
| 
       87 
     | 
    
         
            -
                end
         
     | 
| 
       88 
     | 
    
         
            -
              end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
74 
     | 
    
         
             
              describe '#create_records' do
         
     | 
| 
       91 
75 
     | 
    
         
             
                it 'creates sections' do
         
     | 
| 
       92 
76 
     | 
    
         
             
                  CoalescingPanda::Section.destroy_all
         
     | 
| 
       93 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 77 
     | 
    
         
            +
                  worker.sync_sections(sections_response)
         
     | 
| 
       94 
78 
     | 
    
         
             
                  expect(CoalescingPanda::Section.count).to eq 1
         
     | 
| 
       95 
79 
     | 
    
         
             
                end
         
     | 
| 
       96 
80 
     | 
    
         | 
| 
       97 
81 
     | 
    
         
             
                it 'creates users' do
         
     | 
| 
       98 
82 
     | 
    
         
             
                  CoalescingPanda::User.destroy_all
         
     | 
| 
       99 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 83 
     | 
    
         
            +
                  worker.sync_users(users_response)
         
     | 
| 
       100 
84 
     | 
    
         
             
                  expect(CoalescingPanda::User.count).to eq 3
         
     | 
| 
       101 
85 
     | 
    
         
             
                end
         
     | 
| 
       102 
86 
     | 
    
         | 
| 
       103 
87 
     | 
    
         
             
                it 'creates enrollments' do
         
     | 
| 
       104 
88 
     | 
    
         
             
                  CoalescingPanda::Enrollment.destroy_all
         
     | 
| 
       105 
     | 
    
         
            -
                  worker. 
     | 
| 
       106 
     | 
    
         
            -
                  worker. 
     | 
| 
       107 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 89 
     | 
    
         
            +
                  worker.sync_sections(sections_response)
         
     | 
| 
      
 90 
     | 
    
         
            +
                  worker.sync_users(users_response)
         
     | 
| 
      
 91 
     | 
    
         
            +
                  worker.sync_enrollments(enrollments_response)
         
     | 
| 
       108 
92 
     | 
    
         
             
                  expect(CoalescingPanda::Enrollment.count).to eq 3
         
     | 
| 
       109 
93 
     | 
    
         
             
                  expect(CoalescingPanda::Enrollment.last.workflow_state).to eq "active"
         
     | 
| 
       110 
94 
     | 
    
         
             
                end
         
     | 
| 
       111 
95 
     | 
    
         | 
| 
       112 
96 
     | 
    
         
             
                it 'creates assignments' do
         
     | 
| 
       113 
97 
     | 
    
         
             
                  CoalescingPanda::Assignment.destroy_all
         
     | 
| 
       114 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 98 
     | 
    
         
            +
                  worker.sync_assignments(assignments_response)
         
     | 
| 
       115 
99 
     | 
    
         
             
                  expect(CoalescingPanda::Assignment.count).to eq 2
         
     | 
| 
       116 
100 
     | 
    
         
             
                end
         
     | 
| 
       117 
101 
     | 
    
         | 
| 
       118 
102 
     | 
    
         
             
                it 'creates submissions' do
         
     | 
| 
       119 
103 
     | 
    
         
             
                  CoalescingPanda::Submission.destroy_all
         
     | 
| 
       120 
104 
     | 
    
         
             
                  submissions_response = submissions_response1 + submissions_response2
         
     | 
| 
       121 
     | 
    
         
            -
                  worker. 
     | 
| 
       122 
     | 
    
         
            -
                  worker. 
     | 
| 
       123 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 105 
     | 
    
         
            +
                  worker.sync_sections(sections_response)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  worker.sync_users(users_response)
         
     | 
| 
      
 107 
     | 
    
         
            +
                  worker.sync_enrollments(enrollments_response)
         
     | 
| 
      
 108 
     | 
    
         
            +
                  worker.sync_assignments(assignments_response)
         
     | 
| 
      
 109 
     | 
    
         
            +
                  worker.sync_submissions(submissions_response)
         
     | 
| 
       124 
110 
     | 
    
         
             
                  expect(CoalescingPanda::Submission.count).to eq 4
         
     | 
| 
       125 
111 
     | 
    
         
             
                end
         
     | 
| 
       126 
112 
     | 
    
         | 
| 
       127 
113 
     | 
    
         
             
                it 'creates groups' do
         
     | 
| 
       128 
114 
     | 
    
         
             
                  CoalescingPanda::Group.destroy_all
         
     | 
| 
       129 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 115 
     | 
    
         
            +
                  worker.sync_groups(groups_response)
         
     | 
| 
       130 
116 
     | 
    
         
             
                  expect(CoalescingPanda::Group.count).to eq 2
         
     | 
| 
       131 
117 
     | 
    
         
             
                end
         
     | 
| 
       132 
118 
     | 
    
         | 
| 
       133 
119 
     | 
    
         
             
                it 'creates group memberships' do
         
     | 
| 
       134 
120 
     | 
    
         
             
                  CoalescingPanda::GroupMembership.destroy_all
         
     | 
| 
       135 
     | 
    
         
            -
                  worker. 
     | 
| 
      
 121 
     | 
    
         
            +
                  worker.sync_group_memberships(membership_response)
         
     | 
| 
       136 
122 
     | 
    
         
             
                  expect(CoalescingPanda::GroupMembership.count).to eq 2
         
     | 
| 
       137 
123 
     | 
    
         
             
                end
         
     | 
| 
       138 
124 
     | 
    
         
             
              end
         
     | 
| 
         @@ -183,54 +169,4 @@ RSpec.describe CoalescingPanda::Workers::CourseMiner, :type => :model do 
     | 
|
| 
       183 
169 
     | 
    
         
             
                  expect(worker.standard_attributes(record, attributes)).to eq({"workflow_state" => "accepted"})
         
     | 
| 
       184 
170 
     | 
    
         
             
                end
         
     | 
| 
       185 
171 
     | 
    
         
             
              end
         
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
              describe '#sis_id' do
         
     | 
| 
       188 
     | 
    
         
            -
                it 'returns sis_source_id if one exists' do
         
     | 
| 
       189 
     | 
    
         
            -
                  values = {"sis_source_id" => "1234"}
         
     | 
| 
       190 
     | 
    
         
            -
                  expect(worker.sis_id(:users, values)).to eq "1234"
         
     | 
| 
       191 
     | 
    
         
            -
                end
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
                it 'returns sis_section_id if one exists' do
         
     | 
| 
       194 
     | 
    
         
            -
                  values = {"sis_section_id" => "2345"}
         
     | 
| 
       195 
     | 
    
         
            -
                  expect(worker.sis_id(:sections, values)).to eq "2345"
         
     | 
| 
       196 
     | 
    
         
            -
                end
         
     | 
| 
       197 
     | 
    
         
            -
             
     | 
| 
       198 
     | 
    
         
            -
                it 'returns nil if no valid sis_id' do
         
     | 
| 
       199 
     | 
    
         
            -
                  values = {"not_valid_key" => "2345"}
         
     | 
| 
       200 
     | 
    
         
            -
                  expect(worker.sis_id(:sections, values)).to eq nil
         
     | 
| 
       201 
     | 
    
         
            -
                end
         
     | 
| 
       202 
     | 
    
         
            -
              end
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
              describe '#create_associations' do
         
     | 
| 
       205 
     | 
    
         
            -
                let(:user) { FactoryGirl.create(:user, account: course.account) }
         
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
                it 'sets a user records account' do
         
     | 
| 
       208 
     | 
    
         
            -
                  record = CoalescingPanda::User.new
         
     | 
| 
       209 
     | 
    
         
            -
                  worker.create_associations(record, :users, {})
         
     | 
| 
       210 
     | 
    
         
            -
                  expect(record.account).to eq course.account
         
     | 
| 
       211 
     | 
    
         
            -
                end
         
     | 
| 
       212 
     | 
    
         
            -
             
     | 
| 
       213 
     | 
    
         
            -
                it 'sets an enrollments user and section' do
         
     | 
| 
       214 
     | 
    
         
            -
                  section = FactoryGirl.create(:section)
         
     | 
| 
       215 
     | 
    
         
            -
                  course.sections << section
         
     | 
| 
       216 
     | 
    
         
            -
                  record = CoalescingPanda::Enrollment.new
         
     | 
| 
       217 
     | 
    
         
            -
                  worker.create_associations(record, :enrollments, {'user_id' => user.canvas_user_id, 'course_section_id' => section.canvas_section_id})
         
     | 
| 
       218 
     | 
    
         
            -
                  expect(record.user).to eq user
         
     | 
| 
       219 
     | 
    
         
            -
                  expect(record.section).to eq section
         
     | 
| 
       220 
     | 
    
         
            -
                end
         
     | 
| 
       221 
     | 
    
         
            -
             
     | 
| 
       222 
     | 
    
         
            -
                it 'sets an assignments course' do
         
     | 
| 
       223 
     | 
    
         
            -
                  record = CoalescingPanda::Assignment.new
         
     | 
| 
       224 
     | 
    
         
            -
                  worker.create_associations(record, :assignments, {})
         
     | 
| 
       225 
     | 
    
         
            -
                  expect(record.course).to eq course
         
     | 
| 
       226 
     | 
    
         
            -
                end
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
                it 'sets an submissions' do
         
     | 
| 
       229 
     | 
    
         
            -
                  assignment = FactoryGirl.create(:assignment, course: course)
         
     | 
| 
       230 
     | 
    
         
            -
                  record = CoalescingPanda::Submission.new
         
     | 
| 
       231 
     | 
    
         
            -
                  worker.create_associations(record, :submissions, {'user_id' => user.canvas_user_id, 'assignment_id' => assignment.canvas_assignment_id})
         
     | 
| 
       232 
     | 
    
         
            -
                  expect(record.user).to eq user
         
     | 
| 
       233 
     | 
    
         
            -
                  expect(record.assignment).to eq assignment
         
     | 
| 
       234 
     | 
    
         
            -
                end
         
     | 
| 
       235 
     | 
    
         
            -
              end
         
     | 
| 
       236 
172 
     | 
    
         
             
            end
         
     | 
    
        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 
     | 
    
         
            +
              version: 4.0.0
         
     | 
| 
       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-03- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2015-03-13 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rails
         
     |