canvas_sync 0.9.4 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/lib/canvas_sync/api_syncable.rb +1 -0
  4. data/lib/canvas_sync/generators/install_generator.rb +3 -3
  5. data/lib/canvas_sync/generators/templates/migrations/create_accounts.rb +17 -0
  6. data/lib/canvas_sync/generators/templates/{models → migrations}/create_admins.rb +2 -2
  7. data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignment_groups.rb +2 -2
  8. data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignments.rb +7 -7
  9. data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_module_items.rb +4 -4
  10. data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_modules.rb +2 -2
  11. data/lib/canvas_sync/generators/templates/{models → migrations}/create_courses.rb +7 -8
  12. data/lib/canvas_sync/generators/templates/{models → migrations}/create_enrollments.rb +4 -6
  13. data/lib/canvas_sync/generators/templates/{models → migrations}/create_roles.rb +2 -2
  14. data/lib/canvas_sync/generators/templates/{models → migrations}/create_sections.rb +5 -5
  15. data/lib/canvas_sync/generators/templates/{models → migrations}/create_submissions.rb +2 -2
  16. data/lib/canvas_sync/generators/templates/{models → migrations}/create_terms.rb +2 -2
  17. data/lib/canvas_sync/generators/templates/{models → migrations}/create_users.rb +4 -4
  18. data/lib/canvas_sync/generators/templates/models/account.rb +4 -4
  19. data/lib/canvas_sync/generators/templates/models/admin.rb +4 -4
  20. data/lib/canvas_sync/generators/templates/models/assignment.rb +10 -9
  21. data/lib/canvas_sync/generators/templates/models/assignment_group.rb +5 -5
  22. data/lib/canvas_sync/generators/templates/models/context_module.rb +2 -2
  23. data/lib/canvas_sync/generators/templates/models/context_module_item.rb +3 -2
  24. data/lib/canvas_sync/generators/templates/models/course.rb +14 -14
  25. data/lib/canvas_sync/generators/templates/models/enrollment.rb +10 -9
  26. data/lib/canvas_sync/generators/templates/models/role.rb +3 -3
  27. data/lib/canvas_sync/generators/templates/models/section.rb +6 -6
  28. data/lib/canvas_sync/generators/templates/models/submission.rb +5 -5
  29. data/lib/canvas_sync/generators/templates/models/term.rb +4 -3
  30. data/lib/canvas_sync/generators/templates/models/user.rb +6 -6
  31. data/lib/canvas_sync/generators/templates/services/live_events/base_event.rb +4 -0
  32. data/lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb +1 -1
  33. data/lib/canvas_sync/generators/templates/services/live_events/course_section/course_section_event.rb +4 -4
  34. data/lib/canvas_sync/generators/templates/services/live_events/module/module_event.rb +1 -1
  35. data/lib/canvas_sync/generators/templates/services/live_events/module_item/module_item_event.rb +3 -3
  36. data/lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb +1 -1
  37. data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +7 -2
  38. data/lib/canvas_sync/jobs/sync_simple_table_job.rb +7 -2
  39. data/lib/canvas_sync/processors/model_mappings.yml +35 -41
  40. data/lib/canvas_sync/version.rb +1 -1
  41. data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +4 -4
  42. data/spec/canvas_sync/jobs/sync_simple_table_job_spec.rb +3 -3
  43. data/spec/canvas_sync/models/accounts_spec.rb +2 -2
  44. data/spec/canvas_sync/models/admins_spec.rb +3 -3
  45. data/spec/canvas_sync/models/assignment_group_spec.rb +4 -4
  46. data/spec/canvas_sync/models/assignment_spec.rb +8 -8
  47. data/spec/canvas_sync/models/context_module_spec.rb +2 -2
  48. data/spec/canvas_sync/models/course_spec.rb +7 -8
  49. data/spec/canvas_sync/models/enrollment_spec.rb +5 -5
  50. data/spec/canvas_sync/models/roles_spec.rb +3 -3
  51. data/spec/canvas_sync/models/section_spec.rb +4 -4
  52. data/spec/canvas_sync/models/submission_spec.rb +5 -5
  53. data/spec/canvas_sync/models/term_spec.rb +7 -7
  54. data/spec/canvas_sync/models/user_spec.rb +4 -4
  55. data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +5 -5
  56. data/spec/canvas_sync/services/module_event_spec.rb +1 -1
  57. data/spec/canvas_sync/services/module_item_event_spec.rb +7 -7
  58. data/spec/dummy/app/models/account.rb +9 -1
  59. data/spec/dummy/app/models/admin.rb +4 -4
  60. data/spec/dummy/app/models/assignment.rb +23 -5
  61. data/spec/dummy/app/models/assignment_group.rb +15 -3
  62. data/spec/dummy/app/models/context_module.rb +2 -2
  63. data/spec/dummy/app/models/context_module_item.rb +3 -2
  64. data/spec/dummy/app/models/course.rb +20 -7
  65. data/spec/dummy/app/models/enrollment.rb +20 -4
  66. data/spec/dummy/app/models/role.rb +3 -3
  67. data/spec/dummy/app/models/section.rb +14 -3
  68. data/spec/dummy/app/models/submission.rb +16 -4
  69. data/spec/dummy/app/models/term.rb +4 -3
  70. data/spec/dummy/app/models/user.rb +15 -4
  71. data/spec/dummy/app/services/live_events/base_event.rb +4 -0
  72. data/spec/dummy/app/services/live_events/course_event.rb +1 -1
  73. data/spec/dummy/app/services/live_events/course_section_event.rb +4 -4
  74. data/spec/dummy/app/services/live_events/module_event.rb +1 -1
  75. data/spec/dummy/app/services/live_events/module_item_event.rb +3 -3
  76. data/spec/dummy/app/services/live_events/user_event.rb +1 -1
  77. data/spec/dummy/db/migrate/{20180216171618_create_submissions.rb → 20190521003447_create_submissions.rb} +4 -4
  78. data/spec/dummy/db/migrate/{20180103162102_create_roles.rb → 20190521003448_create_roles.rb} +2 -2
  79. data/spec/dummy/db/migrate/{20180109210452_create_admins.rb → 20190521003449_create_admins.rb} +2 -2
  80. data/spec/dummy/db/migrate/{20180222163506_create_assignment_groups.rb → 20190521003450_create_assignment_groups.rb} +2 -2
  81. data/spec/dummy/db/migrate/{20180411215348_create_context_modules.rb → 20190521003451_create_context_modules.rb} +2 -2
  82. data/spec/dummy/db/migrate/{20180215214227_create_assignments.rb → 20190603192310_create_assignments.rb} +11 -11
  83. data/spec/dummy/db/migrate/{20180605172338_create_context_module_items.rb → 20190603193502_create_context_module_items.rb} +4 -4
  84. data/spec/dummy/db/migrate/{20180509194201_create_users.rb → 20190603215718_create_users.rb} +4 -4
  85. data/spec/dummy/db/migrate/{20170906193506_create_terms.rb → 20190603215721_create_terms.rb} +2 -2
  86. data/spec/dummy/db/migrate/{20171107213207_create_sections.rb → 20190603215722_create_sections.rb} +5 -5
  87. data/spec/dummy/db/migrate/{20170914181345_create_courses.rb → 20190603220011_create_courses.rb} +7 -8
  88. data/spec/dummy/db/migrate/{20170905192509_create_enrollments.rb → 20190603220013_create_enrollments.rb} +4 -6
  89. data/spec/dummy/db/migrate/{20180220172559_create_accounts.rb → 20190604193942_create_accounts.rb} +6 -6
  90. data/spec/dummy/db/schema.rb +56 -58
  91. data/spec/dummy/log/test.log +1350 -0
  92. data/spec/factories/account_factory.rb +5 -5
  93. data/spec/factories/admin_factory.rb +1 -1
  94. data/spec/factories/assignment_factory.rb +1 -1
  95. data/spec/factories/assignment_group_factory.rb +1 -1
  96. data/spec/factories/context_module_factory.rb +2 -2
  97. data/spec/factories/context_module_item_factory.rb +1 -1
  98. data/spec/factories/course_factory.rb +5 -5
  99. data/spec/factories/enrollment_factory.rb +1 -1
  100. data/spec/factories/role_factory.rb +1 -1
  101. data/spec/factories/section_factory.rb +1 -1
  102. data/spec/factories/submission_factory.rb +1 -1
  103. data/spec/factories/term_factory.rb +1 -1
  104. data/spec/factories/user_factory.rb +1 -1
  105. data/spec/spec_helper.rb +1 -0
  106. metadata +41 -41
  107. data/lib/canvas_sync/generators/templates/models/create_accounts.rb +0 -17
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.9.4".freeze
2
+ VERSION = "0.10.0".freeze
3
3
  end
@@ -11,7 +11,7 @@ RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
11
11
 
12
12
  it 'enqueues a ReportStarter for a provisioning report for the specified models for each term' do
13
13
  expected_job_chain = Marshal.load(Marshal.dump(job_chain))
14
- expected_job_chain[:global_options][:canvas_term_id] = active_term_1.canvas_term_id
14
+ expected_job_chain[:global_options][:canvas_term_id] = active_term_1.canvas_id
15
15
 
16
16
  expect(CanvasSync::Jobs::ReportStarter).to receive(:perform_later)
17
17
  .with(
@@ -21,14 +21,14 @@ RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
21
21
  "parameters[include_deleted]" => true,
22
22
  "parameters[users]" => true,
23
23
  "parameters[courses]" => true,
24
- "parameters[enrollment_term_id]" => active_term_1.canvas_term_id
24
+ "parameters[enrollment_term_id]" => active_term_1.canvas_id
25
25
  },
26
26
  CanvasSync::Processors::ProvisioningReportProcessor.to_s,
27
27
  { models: ['users', 'courses'], term_scope: 'active' }
28
28
  )
29
29
 
30
30
  expected_job_chain_2 = Marshal.load(Marshal.dump(job_chain))
31
- expected_job_chain_2[:global_options][:canvas_term_id] = active_term_2.canvas_term_id
31
+ expected_job_chain_2[:global_options][:canvas_term_id] = active_term_2.canvas_id
32
32
 
33
33
  expect(CanvasSync::Jobs::ReportStarter).to receive(:perform_later)
34
34
  .with(
@@ -38,7 +38,7 @@ RSpec.describe CanvasSync::Jobs::SyncProvisioningReportJob do
38
38
  "parameters[include_deleted]" => true,
39
39
  "parameters[users]" => true,
40
40
  "parameters[courses]" => true,
41
- "parameters[enrollment_term_id]" => active_term_2.canvas_term_id
41
+ "parameters[enrollment_term_id]" => active_term_2.canvas_id
42
42
  },
43
43
  CanvasSync::Processors::ProvisioningReportProcessor.to_s,
44
44
  { models: ['users', 'courses'], term_scope: 'active' }
@@ -10,7 +10,7 @@ RSpec.describe CanvasSync::Jobs::SyncSimpleTableJob do
10
10
 
11
11
  it 'enqueues a ReportStarter for a provisioning report for the specified model for a term' do
12
12
  expected_job_chain = Marshal.load(Marshal.dump(job_chain))
13
- expected_job_chain[:global_options][:canvas_term_id] = active_term_1.canvas_term_id
13
+ expected_job_chain[:global_options][:canvas_term_id] = active_term_1.canvas_id
14
14
 
15
15
  expect(CanvasSync::Jobs::ReportStarter).to receive(:perform_later)
16
16
  .with(
@@ -19,7 +19,7 @@ RSpec.describe CanvasSync::Jobs::SyncSimpleTableJob do
19
19
  {
20
20
  "parameters[include_deleted]" => true,
21
21
  "parameters[courses]" => true,
22
- "parameters[enrollment_term_id]" => active_term_1.canvas_term_id
22
+ "parameters[enrollment_term_id]" => active_term_1.canvas_id
23
23
  },
24
24
  CanvasSync::Processors::NormalProcessor.to_s,
25
25
  {
@@ -31,7 +31,7 @@ RSpec.describe CanvasSync::Jobs::SyncSimpleTableJob do
31
31
  params: {
32
32
  "parameters[include_deleted]" => true,
33
33
  "parameters[courses]" => true,
34
- "parameters[enrollment_term_id]" => active_term_1.canvas_term_id
34
+ "parameters[enrollment_term_id]" => active_term_1.canvas_id
35
35
  }
36
36
  }
37
37
  )
@@ -4,8 +4,8 @@ RSpec.describe Account, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:account) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_account_id) }
8
- it { should validate_uniqueness_of(:canvas_account_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  end
@@ -4,8 +4,8 @@ RSpec.describe Admin, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:admin) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_admin_id) }
8
- it { should validate_uniqueness_of(:canvas_admin_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe '.create_or_update' do
@@ -27,7 +27,7 @@ RSpec.describe Admin, type: :model do
27
27
  end
28
28
 
29
29
  context 'the admin already exists' do
30
- let!(:existing_admin) { FactoryGirl.create(:admin, canvas_admin_id: admin_params['id']) }
30
+ let!(:existing_admin) { FactoryGirl.create(:admin, canvas_id: admin_params['id']) }
31
31
 
32
32
  it 'updates it' do
33
33
  expect {
@@ -4,20 +4,20 @@ RSpec.describe AssignmentGroup, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:assignment_group) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_assignment_group_id) }
8
- it { should validate_uniqueness_of(:canvas_assignment_group_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should belong_to(:course)
14
- .with_primary_key(:canvas_course_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_course_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should have_many(:assignments)
20
- .with_primary_key(:canvas_assignment_group_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_assignment_group_id)
22
22
  end
23
23
  end
@@ -4,27 +4,27 @@ RSpec.describe Assignment, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:assignment) }
5
5
 
6
6
  describe "validations" do
7
- it { should validate_presence_of(:canvas_assignment_id) }
8
- it { should validate_uniqueness_of(:canvas_assignment_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe "associations" do
12
12
  it do
13
13
  should have_many(:submissions)
14
- .with_primary_key(:canvas_assignment_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_assignment_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should belong_to(:assignment_group)
20
- .with_primary_key(:canvas_assignment_group_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_assignment_group_id)
22
22
  end
23
23
 
24
24
  it do
25
25
  should have_many(:context_module_items)
26
- .with_primary_key(:canvas_assignment_id)
27
- .with_foreign_key(:content_id)
26
+ .with_primary_key(:canvas_id)
27
+ .with_foreign_key(:canvas_content_id)
28
28
  .dependent(:destroy)
29
29
  end
30
30
 
@@ -35,10 +35,10 @@ RSpec.describe Assignment, type: :model do
35
35
  let!(:matching_course) { FactoryGirl.create(:course) }
36
36
 
37
37
  before do
38
- subject.update_attributes(context_type: "Course", context_id: matching_course.canvas_course_id)
38
+ subject.update_attributes(canvas_context_type: "Course", canvas_context_id: matching_course.canvas_id)
39
39
  end
40
40
 
41
- it "should belong to courses where the context_type is Course and context_id is the canvas_course_id" do
41
+ it "should belong to courses where the canvas_context_type is Course and canvas_context_id is the canvas_course_id" do
42
42
  expect(subject.context).to eq(matching_course)
43
43
  end
44
44
  end
@@ -5,12 +5,12 @@ RSpec.describe ContextModule, type: :model do
5
5
 
6
6
  describe "associations" do
7
7
  it do
8
- should belong_to(:canvas_context)
8
+ should belong_to(:context)
9
9
  end
10
10
 
11
11
  it do
12
12
  should have_many(:context_module_items)
13
- .with_primary_key(:canvas_context_module_id)
13
+ .with_primary_key(:canvas_id)
14
14
  .with_foreign_key(:canvas_context_module_id)
15
15
  end
16
16
 
@@ -4,43 +4,42 @@ RSpec.describe Course, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:course) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_course_id) }
8
- it { should validate_uniqueness_of(:canvas_course_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should belong_to(:term)
14
- .with_primary_key(:canvas_term_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_term_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should have_many(:enrollments)
20
- .with_primary_key(:canvas_course_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_course_id)
22
22
  end
23
23
 
24
24
  it do
25
25
  should have_many(:sections)
26
- .with_primary_key(:canvas_course_id)
26
+ .with_primary_key(:canvas_id)
27
27
  .with_foreign_key(:canvas_course_id)
28
28
  end
29
29
 
30
30
  it do
31
31
  should have_many(:assignment_groups)
32
- .with_primary_key(:canvas_course_id)
32
+ .with_primary_key(:canvas_id)
33
33
  .with_foreign_key(:canvas_course_id)
34
34
  end
35
35
 
36
36
  it do
37
37
  should have_many(:assignments)
38
- .with_primary_key(:canvas_course_id)
38
+ .with_primary_key(:canvas_id)
39
39
  end
40
40
 
41
41
  it do
42
42
  should have_many(:submissions)
43
- .with_primary_key(:canvas_course_id)
44
43
  end
45
44
  end
46
45
  end
@@ -4,26 +4,26 @@ RSpec.describe Enrollment, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:enrollment) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_enrollment_id) }
8
- it { should validate_uniqueness_of(:canvas_enrollment_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should belong_to(:user)
14
- .with_primary_key(:canvas_user_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_user_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should belong_to(:course)
20
- .with_primary_key(:canvas_course_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_course_id)
22
22
  end
23
23
 
24
24
  it do
25
25
  should belong_to(:section)
26
- .with_primary_key(:canvas_section_id)
26
+ .with_primary_key(:canvas_id)
27
27
  .with_foreign_key(:canvas_section_id)
28
28
  end
29
29
  end
@@ -4,8 +4,8 @@ RSpec.describe Role, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:role) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_role_id) }
8
- it { should validate_uniqueness_of(:canvas_role_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe '.create_or_update' do
@@ -27,7 +27,7 @@ RSpec.describe Role, type: :model do
27
27
  end
28
28
 
29
29
  context 'the role already exists' do
30
- let!(:existing_role) { FactoryGirl.create(:role, canvas_role_id: role_params['id']) }
30
+ let!(:existing_role) { FactoryGirl.create(:role, canvas_id: role_params['id']) }
31
31
 
32
32
  it 'updates it' do
33
33
  expect {
@@ -4,20 +4,20 @@ RSpec.describe Section, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:section) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_section_id) }
8
- it { should validate_uniqueness_of(:canvas_section_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should belong_to(:course)
14
- .with_primary_key(:canvas_course_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_course_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should have_many(:enrollments)
20
- .with_primary_key(:canvas_section_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_section_id)
22
22
  end
23
23
  end
@@ -4,26 +4,26 @@ RSpec.describe Submission, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:submission) }
5
5
 
6
6
  describe "validations" do
7
- it { should validate_presence_of(:canvas_submission_id) }
8
- it { should validate_uniqueness_of(:canvas_submission_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should belong_to(:user)
14
- .with_primary_key(:canvas_user_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_user_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should belong_to(:assignment)
20
- .with_primary_key(:canvas_assignment_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_assignment_id)
22
22
  end
23
23
 
24
24
  it do
25
25
  should belong_to(:course)
26
- .with_primary_key(:canvas_course_id)
26
+ .with_primary_key(:canvas_id)
27
27
  .with_foreign_key(:canvas_course_id)
28
28
  end
29
29
  end
@@ -4,14 +4,14 @@ RSpec.describe Term, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:term) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_term_id) }
8
- it { should validate_uniqueness_of(:canvas_term_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should have_many(:courses)
14
- .with_primary_key(:canvas_term_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_term_id)
16
16
  end
17
17
  end
@@ -23,7 +23,7 @@ RSpec.describe Term, type: :model do
23
23
  let!(:completed_term) { FactoryGirl.create(:term, start_at: 2.months.ago, end_at: 1.month.ago) }
24
24
  let!(:unstarted_term) { FactoryGirl.create(:term, start_at: 6.months.from_now, end_at: 1.year.from_now) }
25
25
 
26
- it 'returns terms with an active workflow_state that have a start_date 15 days in the future or earlier and an end_date 15 days in the past or later' do
26
+ it 'returns terms with an active workflow_state that have a start_at 15 days in the future or earlier and an end_at 15 days in the past or later' do
27
27
  expect(Term.active).to match_array([active_term])
28
28
  end
29
29
  end
@@ -42,7 +42,7 @@ RSpec.describe Term, type: :model do
42
42
  expect(term.name).to eq(term_params['name'])
43
43
  expect(term.start_at).to eq(term_params['start_at'])
44
44
  expect(term.end_at).to eq(term_params['end_at'])
45
- expect(term.canvas_term_id).to eq(term_params['id'])
45
+ expect(term.canvas_id).to eq(term_params['id'])
46
46
  expect(term.grading_period_group_id).to eq(term_params['grading_period_group_id'])
47
47
  expect(term.sis_id).to eq(term_params['sis_term_id'])
48
48
  expect(term.workflow_state).to eq(term_params['workflow_state'])
@@ -50,7 +50,7 @@ RSpec.describe Term, type: :model do
50
50
  end
51
51
 
52
52
  context 'the term already exists' do
53
- let!(:existing_term) { FactoryGirl.create(:term, canvas_term_id: term_params['id']) }
53
+ let!(:existing_term) { FactoryGirl.create(:term, canvas_id: term_params['id']) }
54
54
 
55
55
  it 'updates it' do
56
56
  expect {
@@ -61,7 +61,7 @@ RSpec.describe Term, type: :model do
61
61
  expect(existing_term.name).to eq(term_params['name'])
62
62
  expect(existing_term.start_at).to eq(term_params['start_at'])
63
63
  expect(existing_term.end_at).to eq(term_params['end_at'])
64
- expect(existing_term.canvas_term_id).to eq(term_params['id'])
64
+ expect(existing_term.canvas_id).to eq(term_params['id'])
65
65
  expect(existing_term.grading_period_group_id).to eq(term_params['grading_period_group_id'])
66
66
  expect(existing_term.sis_id).to eq(term_params['sis_term_id'])
67
67
  expect(existing_term.workflow_state).to eq(term_params['workflow_state'])
@@ -4,20 +4,20 @@ RSpec.describe User, type: :model do
4
4
  let(:subject) { FactoryGirl.create(:user) }
5
5
 
6
6
  describe 'validations' do
7
- it { should validate_presence_of(:canvas_user_id) }
8
- it { should validate_uniqueness_of(:canvas_user_id) }
7
+ it { should validate_presence_of(:canvas_id) }
8
+ it { should validate_uniqueness_of(:canvas_id) }
9
9
  end
10
10
 
11
11
  describe 'associations' do
12
12
  it do
13
13
  should have_many(:enrollments)
14
- .with_primary_key(:canvas_user_id)
14
+ .with_primary_key(:canvas_id)
15
15
  .with_foreign_key(:canvas_user_id)
16
16
  end
17
17
 
18
18
  it do
19
19
  should have_many(:submissions)
20
- .with_primary_key(:canvas_user_id)
20
+ .with_primary_key(:canvas_id)
21
21
  .with_foreign_key(:canvas_user_id)
22
22
  end
23
23
  end
@@ -15,8 +15,8 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
15
15
  subject.process('spec/support/fixtures/reports/courses.csv', { models: ['courses'] }, 1)
16
16
  }.to change { Course.count }.by(2)
17
17
  course = Course.first
18
- expect(course.start_date).to eq DateTime.parse("2017-03-27 21:53:18")
19
- expect(course.end_date).to eq DateTime.parse("2017-04-27 12:21:18")
18
+ expect(course.start_at).to eq DateTime.parse("2017-03-27 21:53:18")
19
+ expect(course.end_at).to eq DateTime.parse("2017-04-27 12:21:18")
20
20
  end
21
21
 
22
22
  it 'processes enrollments' do
@@ -30,15 +30,15 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
30
30
  subject.process('spec/support/fixtures/reports/sections.csv', { models: ['sections'] }, 1)
31
31
  }.to change { Section.count }.by(2)
32
32
  section = Section.first
33
- expect(section.start_date).to eq DateTime.parse("2017-03-27 21:53:18")
34
- expect(section.end_date).to eq DateTime.parse("2017-03-27 21:53:18")
33
+ expect(section.start_at).to eq DateTime.parse("2017-03-27 21:53:18")
34
+ expect(section.end_at).to eq DateTime.parse("2017-03-27 21:53:18")
35
35
  end
36
36
 
37
37
  it 'processes xlist' do
38
38
  subject.process('spec/support/fixtures/reports/xlist.csv', { models: ['xlist'] }, 1)
39
39
  expect(Section.where.not(canvas_nonxlist_course_id: nil).count).to eq 1
40
40
  cross_listed_section = Section.where.not(canvas_nonxlist_course_id: nil).first
41
- expect(cross_listed_section.canvas_section_id).to eq 2
41
+ expect(cross_listed_section.canvas_id).to eq 2
42
42
  expect(cross_listed_section.canvas_nonxlist_course_id).to eq 2
43
43
  end
44
44