coalescing_panda 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/coalescing_panda/lti_controller.rb +1 -0
  3. data/app/models/coalescing_panda/assignment.rb +8 -0
  4. data/app/models/coalescing_panda/canvas_api_auth.rb +0 -2
  5. data/app/models/coalescing_panda/course.rb +11 -0
  6. data/app/models/coalescing_panda/enrollment.rb +8 -0
  7. data/app/models/coalescing_panda/lti_account.rb +10 -6
  8. data/app/models/coalescing_panda/lti_nonce.rb +0 -2
  9. data/app/models/coalescing_panda/section.rb +9 -0
  10. data/app/models/coalescing_panda/session.rb +0 -1
  11. data/app/models/coalescing_panda/submission.rb +8 -0
  12. data/app/models/coalescing_panda/term.rb +6 -0
  13. data/app/models/coalescing_panda/user.rb +9 -0
  14. data/app/models/coalescing_panda/workers/course_miner.rb +91 -0
  15. data/db/migrate/20131118211442_create_coalescing_panda_lti_accounts.rb +0 -1
  16. data/db/migrate/20141119225319_create_coalescing_panda_terms.rb +19 -0
  17. data/db/migrate/20141119225721_create_coalescing_panda_courses.rb +22 -0
  18. data/db/migrate/20141120151432_create_coalescing_panda_sections.rb +19 -0
  19. data/db/migrate/20141120151940_create_coalescing_panda_assignments.rb +22 -0
  20. data/db/migrate/20141120152458_create_coalescing_panda_users.rb +19 -0
  21. data/db/migrate/20141120152546_create_coalescing_panda_submissions.rb +19 -0
  22. data/db/migrate/20141120153135_create_coalescing_panda_enrollments.rb +19 -0
  23. data/db/migrate/20141120205729_add_canvas_account_id_to_lti_account.rb +5 -0
  24. data/lib/coalescing_panda/engine.rb +5 -0
  25. data/lib/coalescing_panda/version.rb +1 -1
  26. data/spec/controllers/coalescing_panda/lti_controller_spec.rb +1 -6
  27. data/spec/controllers/coalescing_panda/oauth2_controller_spec.rb +1 -1
  28. data/spec/dummy/config/application.rb +3 -0
  29. data/spec/dummy/db/schema.rb +120 -1
  30. data/spec/factories/accounts.rb +19 -0
  31. data/spec/factories/assignments.rb +9 -0
  32. data/spec/factories/courses.rb +7 -0
  33. data/spec/factories/enrollments.rb +7 -0
  34. data/spec/factories/submissions.rb +8 -0
  35. data/spec/factories/users.rb +29 -0
  36. data/spec/models/coalescing_panda/assignment_spec.rb +18 -0
  37. data/spec/models/coalescing_panda/course_spec.rb +37 -0
  38. data/spec/models/coalescing_panda/enrollment_spec.rb +17 -0
  39. data/spec/models/coalescing_panda/lti_account_spec.rb +17 -0
  40. data/spec/models/coalescing_panda/lti_nonce_spec.rb +5 -0
  41. data/spec/models/coalescing_panda/section_spec.rb +22 -0
  42. data/spec/models/coalescing_panda/submission_spec.rb +18 -0
  43. data/spec/models/coalescing_panda/term_spec.rb +17 -0
  44. data/spec/models/coalescing_panda/user_spec.rb +27 -0
  45. data/spec/rails_helper.rb +45 -0
  46. data/spec/spec_helper.rb +82 -29
  47. metadata +59 -11
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe CoalescingPanda::Oauth2Controller do
3
+ describe CoalescingPanda::Oauth2Controller, :type => :controller do
4
4
  routes { CoalescingPanda::Engine.routes }
5
5
 
6
6
  describe "#redirect" do
@@ -7,6 +7,9 @@ require "coalescing_panda"
7
7
 
8
8
  module Dummy
9
9
  class Application < Rails::Application
10
+ config.generators do |g|
11
+ g.test_framework :rspec
12
+ end
10
13
  # Settings in config/environments/* take precedence over those specified here.
11
14
  # Application configuration should go into files in config/initializers
12
15
  # -- all .rb files in that directory are automatically loaded.
@@ -11,7 +11,26 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140904223159) do
14
+ ActiveRecord::Schema.define(version: 20141120153135) do
15
+
16
+ create_table "coalescing_panda_assignments", force: true do |t|
17
+ t.integer "coalescing_panda_course_id"
18
+ t.string "name"
19
+ t.string "description"
20
+ t.string "canvas_assignment_id"
21
+ t.string "sis_id"
22
+ t.string "workflow_state"
23
+ t.float "points_possible"
24
+ t.datetime "due_at"
25
+ t.datetime "unlock_at"
26
+ t.datetime "lock_at"
27
+ t.datetime "created_at"
28
+ t.datetime "updated_at"
29
+ end
30
+
31
+ add_index "coalescing_panda_assignments", ["canvas_assignment_id"], name: "index_coalescing_panda_assignments_on_canvas_assignment_id"
32
+ add_index "coalescing_panda_assignments", ["coalescing_panda_course_id"], name: "index_assignments_course"
33
+ add_index "coalescing_panda_assignments", ["sis_id"], name: "index_coalescing_panda_assignments_on_sis_id"
15
34
 
16
35
  create_table "coalescing_panda_canvas_api_auths", force: true do |t|
17
36
  t.string "user_id"
@@ -21,6 +40,41 @@ ActiveRecord::Schema.define(version: 20140904223159) do
21
40
  t.datetime "updated_at"
22
41
  end
23
42
 
43
+ create_table "coalescing_panda_courses", force: true do |t|
44
+ t.integer "coalescing_panda_lti_account_id"
45
+ t.integer "coalescing_panda_term_id"
46
+ t.string "name"
47
+ t.string "canvas_course_id"
48
+ t.string "sis_id"
49
+ t.datetime "start_at"
50
+ t.datetime "conclude_at"
51
+ t.string "workflow_state"
52
+ t.string "course_code"
53
+ t.datetime "created_at"
54
+ t.datetime "updated_at"
55
+ end
56
+
57
+ add_index "coalescing_panda_courses", ["canvas_course_id"], name: "index_coalescing_panda_courses_on_canvas_course_id"
58
+ add_index "coalescing_panda_courses", ["coalescing_panda_lti_account_id"], name: "index_courses_account"
59
+ add_index "coalescing_panda_courses", ["coalescing_panda_term_id"], name: "index_courses_term"
60
+ add_index "coalescing_panda_courses", ["sis_id"], name: "index_coalescing_panda_courses_on_sis_id"
61
+
62
+ create_table "coalescing_panda_enrollments", force: true do |t|
63
+ t.integer "coalescing_panda_user_id"
64
+ t.integer "coalescing_panda_section_id"
65
+ t.string "workflow_state"
66
+ t.string "sis_id"
67
+ t.string "canvas_enrollment_id"
68
+ t.datetime "start_at"
69
+ t.datetime "end_at"
70
+ t.datetime "created_at"
71
+ t.datetime "updated_at"
72
+ end
73
+
74
+ add_index "coalescing_panda_enrollments", ["canvas_enrollment_id"], name: "index_coalescing_panda_enrollments_on_canvas_enrollment_id"
75
+ add_index "coalescing_panda_enrollments", ["coalescing_panda_user_id", "coalescing_panda_section_id"], name: "index_enrollments_user_and_assignment"
76
+ add_index "coalescing_panda_enrollments", ["sis_id"], name: "index_coalescing_panda_enrollments_on_sis_id"
77
+
24
78
  create_table "coalescing_panda_lti_accounts", force: true do |t|
25
79
  t.string "name"
26
80
  t.string "key"
@@ -29,6 +83,7 @@ ActiveRecord::Schema.define(version: 20140904223159) do
29
83
  t.string "oauth2_client_key"
30
84
  t.datetime "created_at"
31
85
  t.datetime "updated_at"
86
+ t.text "settings"
32
87
  end
33
88
 
34
89
  create_table "coalescing_panda_lti_nonces", force: true do |t|
@@ -37,6 +92,22 @@ ActiveRecord::Schema.define(version: 20140904223159) do
37
92
  t.datetime "timestamp"
38
93
  end
39
94
 
95
+ create_table "coalescing_panda_sections", force: true do |t|
96
+ t.integer "coalescing_panda_course_id"
97
+ t.string "name"
98
+ t.string "canvas_section_id"
99
+ t.string "sis_id"
100
+ t.string "workflow_state"
101
+ t.datetime "start_at"
102
+ t.datetime "end_at"
103
+ t.datetime "created_at"
104
+ t.datetime "updated_at"
105
+ end
106
+
107
+ add_index "coalescing_panda_sections", ["canvas_section_id"], name: "index_coalescing_panda_sections_on_canvas_section_id"
108
+ add_index "coalescing_panda_sections", ["coalescing_panda_course_id"], name: "index_coalescing_panda_sections_on_coalescing_panda_course_id"
109
+ add_index "coalescing_panda_sections", ["sis_id"], name: "index_coalescing_panda_sections_on_sis_id"
110
+
40
111
  create_table "coalescing_panda_sessions", force: true do |t|
41
112
  t.string "token"
42
113
  t.text "data"
@@ -44,4 +115,52 @@ ActiveRecord::Schema.define(version: 20140904223159) do
44
115
  t.datetime "updated_at"
45
116
  end
46
117
 
118
+ create_table "coalescing_panda_submissions", force: true do |t|
119
+ t.integer "coalescing_panda_user_id"
120
+ t.integer "coalescing_panda_assignment_id"
121
+ t.string "url"
122
+ t.string "grade"
123
+ t.string "score"
124
+ t.datetime "submitted_at"
125
+ t.string "workflow_state"
126
+ t.string "canvas_submission_id"
127
+ t.datetime "created_at"
128
+ t.datetime "updated_at"
129
+ end
130
+
131
+ add_index "coalescing_panda_submissions", ["canvas_submission_id"], name: "index_coalescing_panda_submissions_on_canvas_submission_id"
132
+ add_index "coalescing_panda_submissions", ["coalescing_panda_user_id", "coalescing_panda_assignment_id"], name: "index_submissions_user_and_assignment"
133
+
134
+ create_table "coalescing_panda_terms", force: true do |t|
135
+ t.integer "coalescing_panda_lti_account_id"
136
+ t.string "name"
137
+ t.string "code"
138
+ t.string "sis_id"
139
+ t.string "canvas_term_id"
140
+ t.datetime "start_at"
141
+ t.datetime "end_at"
142
+ t.string "workflow_state"
143
+ t.datetime "created_at"
144
+ t.datetime "updated_at"
145
+ end
146
+
147
+ add_index "coalescing_panda_terms", ["canvas_term_id"], name: "index_coalescing_panda_terms_on_canvas_term_id"
148
+ add_index "coalescing_panda_terms", ["sis_id"], name: "index_coalescing_panda_terms_on_sis_id"
149
+
150
+ create_table "coalescing_panda_users", force: true do |t|
151
+ t.integer "coalescing_panda_lti_account_id"
152
+ t.string "name"
153
+ t.string "email"
154
+ t.string "roles"
155
+ t.string "workflow_state"
156
+ t.string "sis_id"
157
+ t.string "canvas_user_id"
158
+ t.datetime "created_at"
159
+ t.datetime "updated_at"
160
+ end
161
+
162
+ add_index "coalescing_panda_users", ["canvas_user_id"], name: "index_coalescing_panda_users_on_canvas_user_id"
163
+ add_index "coalescing_panda_users", ["coalescing_panda_lti_account_id"], name: "index_users_account"
164
+ add_index "coalescing_panda_users", ["sis_id"], name: "index_coalescing_panda_users_on_sis_id"
165
+
47
166
  end
@@ -0,0 +1,19 @@
1
+ FactoryGirl.define do
2
+ factory :account, class: LtiAccount do
3
+ sequence :name do |n|
4
+ "Account #{n}"
5
+ end
6
+
7
+ sequence :key do |n|
8
+ "Key #{n}"
9
+ end
10
+
11
+ sequence :secret do |n|
12
+ "Account #{n}"
13
+ end
14
+
15
+ oauth2_client_id "1234"
16
+ oauth2_client_key "thisisadeveloperkey"
17
+ settings { {base_url: "http://localhost:3000", account_admin_api_token: "9q2083uy4poiahjfgpoawy"} }
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ FactoryGirl.define do
2
+ factory :assignment do
3
+ name "test assignment"
4
+ course
5
+ sequence :canvas_assignment_id do |n|
6
+ "#{n}"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :course do
3
+ account
4
+ name "Test Course"
5
+ canvas_course_id "1"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ FactoryGirl.define do
2
+ factory :enrollment do
3
+ user
4
+ course
5
+ canvas_enrollment_id '123'
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ FactoryGirl.define do
2
+ factory :submission do
3
+ user
4
+ assignment
5
+ canvas_submission_id '123'
6
+ graded false
7
+ end
8
+ end
@@ -0,0 +1,29 @@
1
+ FactoryGirl.define do
2
+ factory :user do
3
+ sequence :email do |n|
4
+ "test#{n}@test.com"
5
+ end
6
+
7
+ sequence :name do |n|
8
+ "Factory User #{n}"
9
+ end
10
+
11
+ sequence :canvas_user_id do |n|
12
+ n
13
+ end
14
+
15
+ roles []
16
+
17
+ factory :teacher do
18
+ roles [:teacher]
19
+ end
20
+
21
+ factory :student do
22
+ roles [:student]
23
+ end
24
+
25
+ factory :admin do
26
+ roles [:admin]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Assignment, :type => :model do
4
+ let(:assignment) { FactoryGirl.create(:assignment) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a course' do
8
+ expect(CoalescingPanda::Assignment.reflect_on_association(:course)).to_not be_nil
9
+ expect(CoalescingPanda::Assignment.reflect_on_association(:course).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should have many submisssions' do
13
+ expect(CoalescingPanda::Assignment.reflect_on_association(:submissions)).to_not be_nil
14
+ expect(CoalescingPanda::Assignment.reflect_on_association(:submissions).macro).to eql(:has_many)
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Course, :type => :model do
4
+ let(:course) { FactoryGirl.create(:course) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to an account' do
8
+ expect(CoalescingPanda::Course.reflect_on_association(:account)).to_not be_nil
9
+ expect(CoalescingPanda::Course.reflect_on_association(:account).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should belong_to a term' do
13
+ expect(CoalescingPanda::Course.reflect_on_association(:term)).to_not be_nil
14
+ expect(CoalescingPanda::Course.reflect_on_association(:term).macro).to eql(:belongs_to)
15
+ end
16
+
17
+ it 'should have many sections' do
18
+ expect(CoalescingPanda::Course.reflect_on_association(:sections)).to_not be_nil
19
+ expect(CoalescingPanda::Course.reflect_on_association(:sections).macro).to eql(:has_many)
20
+ end
21
+
22
+ it 'should have many assignments' do
23
+ expect(CoalescingPanda::Course.reflect_on_association(:assignments)).to_not be_nil
24
+ expect(CoalescingPanda::Course.reflect_on_association(:assignments).macro).to eql(:has_many)
25
+ end
26
+
27
+ it 'should have many enrollments' do
28
+ expect(CoalescingPanda::Course.reflect_on_association(:enrollments)).to_not be_nil
29
+ expect(CoalescingPanda::Course.reflect_on_association(:enrollments).macro).to eql(:has_many)
30
+ end
31
+
32
+ it 'should have many users' do
33
+ expect(CoalescingPanda::Course.reflect_on_association(:users)).to_not be_nil
34
+ expect(CoalescingPanda::Course.reflect_on_association(:users).macro).to eql(:has_many)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Enrollment, :type => :model do
4
+ let(:enrollment) { FactoryGirl.create(:enrollment) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a user' do
8
+ expect(CoalescingPanda::Enrollment.reflect_on_association(:user)).to_not be_nil
9
+ expect(CoalescingPanda::Enrollment.reflect_on_association(:user).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should belong_to a section' do
13
+ expect(CoalescingPanda::Enrollment.reflect_on_association(:section)).to_not be_nil
14
+ expect(CoalescingPanda::Enrollment.reflect_on_association(:section).macro).to eql(:belongs_to)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::LtiAccount, :type => :model do
4
+ let(:account) { FactoryGirl.create(:account) }
5
+
6
+ context "associations" do
7
+ it 'should have many terms' do
8
+ expect(CoalescingPanda::LtiAccount.reflect_on_association(:terms)).to_not be_nil
9
+ expect(CoalescingPanda::LtiAccount.reflect_on_association(:terms).macro).to eql(:has_many)
10
+ end
11
+
12
+ it 'should have many courses' do
13
+ expect(CoalescingPanda::LtiAccount.reflect_on_association(:courses)).to_not be_nil
14
+ expect(CoalescingPanda::LtiAccount.reflect_on_association(:courses).macro).to eql(:has_many)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::LtiNonce, :type => :model do
4
+
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Section, :type => :model do
4
+ let(:section) { FactoryGirl.create(:section) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a course' do
8
+ expect(CoalescingPanda::Section.reflect_on_association(:course)).to_not be_nil
9
+ expect(CoalescingPanda::Section.reflect_on_association(:course).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should have many enrollments' do
13
+ expect(CoalescingPanda::Section.reflect_on_association(:enrollments)).to_not be_nil
14
+ expect(CoalescingPanda::Section.reflect_on_association(:enrollments).macro).to eql(:has_many)
15
+ end
16
+
17
+ it 'should have many users' do
18
+ expect(CoalescingPanda::Section.reflect_on_association(:users)).to_not be_nil
19
+ expect(CoalescingPanda::Section.reflect_on_association(:users).macro).to eql(:has_many)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Submission, :type => :model do
4
+ let(:submission) { FactoryGirl.create(:submission) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a user' do
8
+ expect(CoalescingPanda::Submission.reflect_on_association(:user)).to_not be_nil
9
+ expect(CoalescingPanda::Submission.reflect_on_association(:user).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should belong_to a assignment' do
13
+ expect(CoalescingPanda::Submission.reflect_on_association(:assignment)).to_not be_nil
14
+ expect(CoalescingPanda::Submission.reflect_on_association(:assignment).macro).to eql(:belongs_to)
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::Term, :type => :model do
4
+ let(:term) { FactoryGirl.create(:term) }
5
+
6
+ context "associations" do
7
+ it 'should belong_to a account' do
8
+ expect(CoalescingPanda::Term.reflect_on_association(:account)).to_not be_nil
9
+ expect(CoalescingPanda::Term.reflect_on_association(:account).macro).to eql(:belongs_to)
10
+ end
11
+
12
+ it 'should belong_to a user' do
13
+ expect(CoalescingPanda::Term.reflect_on_association(:courses)).to_not be_nil
14
+ expect(CoalescingPanda::Term.reflect_on_association(:courses).macro).to eql(:has_many)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe CoalescingPanda::User, :type => :model do
4
+ let(:user) { FactoryGirl.create(:user) }
5
+
6
+ context "associations" do
7
+ it 'should have many enrollments' do
8
+ expect(CoalescingPanda::User.reflect_on_association(:enrollments)).to_not be_nil
9
+ expect(CoalescingPanda::User.reflect_on_association(:enrollments).macro).to eql(:has_many)
10
+ end
11
+
12
+ it 'should have many sections' do
13
+ expect(CoalescingPanda::User.reflect_on_association(:sections)).to_not be_nil
14
+ expect(CoalescingPanda::User.reflect_on_association(:sections).macro).to eql(:has_many)
15
+ end
16
+
17
+ it 'should have many courses' do
18
+ expect(CoalescingPanda::User.reflect_on_association(:courses)).to_not be_nil
19
+ expect(CoalescingPanda::User.reflect_on_association(:courses).macro).to eql(:has_many)
20
+ end
21
+
22
+ it 'should have many submissions' do
23
+ expect(CoalescingPanda::User.reflect_on_association(:submissions)).to_not be_nil
24
+ expect(CoalescingPanda::User.reflect_on_association(:submissions).macro).to eql(:has_many)
25
+ end
26
+ end
27
+ end