canvas_link_migrator 1.0.3 → 1.0.4

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
  SHA256:
3
- metadata.gz: 68ad9b1c1c452ba59ce56cae7ec072c38c185a4b5e4e3457082d8356dc95cd95
4
- data.tar.gz: cc85f34cf8cb4abdb812d6582f213371afc6ccfd0a8ca6bb11f6152367d3d359
3
+ metadata.gz: c3b1e71c22b8899f6fe7b5986ee5569fbb9525c0d4cb9e6eb25c9f6ef1804435
4
+ data.tar.gz: ba9a4fc3a6ce17be40afab0814818fa7b62603e2aee6d6e5e784110c3fb975c0
5
5
  SHA512:
6
- metadata.gz: 8c8c85af3a7357591b9f07ddae0c98649c72880fc134c56cdafb20deb5083d2379020b7c459b191beeb4973f8fab878c831fb39b801b4249f4f8d1407eaec040
7
- data.tar.gz: eded5e2885a8e3be4c22a2878c75e7ad889621f5a0f2bc4b57242656e5800aab0ad87d1ce5d18185b4080c1526f50382b81c49330feb74bf3d90925926cdbea3
6
+ metadata.gz: 191de3ba56873baa45d3f922f7276edcdc0f84eda77fc6627cb9d55e4058b00ec792785b08ad4ef666dd4c0efe95b9cdde289320293466dc598d9a703c3532a8
7
+ data.tar.gz: 4462eb3f2b424ac381ba35a0f9369c2a671d47efdcb7ac9698ebfeeedccaed397e0736f4d321ba366d9620f7734a9aa69621aba128c47a5a317c6559476ae86d
@@ -69,7 +69,7 @@ module CanvasLinkMigrator
69
69
 
70
70
  # Looks up a wiki page slug for a migration id
71
71
  def convert_wiki_page_migration_id_to_slug(migration_id)
72
- resources.dig("wiki_pages", migration_id, "destination", "url")
72
+ resources.dig("wiki_pages", migration_id, "destination", "url") || resources.dig("pages", migration_id, "destination", "url")
73
73
  end
74
74
 
75
75
  # looks up a discussion topic
@@ -25,7 +25,7 @@ describe CanvasLinkMigrator::ImportedHtmlConverter do
25
25
  # tests link_parser and link_resolver
26
26
 
27
27
  describe ".convert" do
28
- before do
28
+ before(:each) do
29
29
  @path = "/courses/2/"
30
30
  @converter = CanvasLinkMigrator::ImportedHtmlConverter.new(resource_map: JSON.parse(File.read("spec/fixtures/canvas_resource_map.json")))
31
31
  end
@@ -44,6 +44,24 @@ describe CanvasLinkMigrator::ImportedHtmlConverter do
44
44
  expect(bad_links).to be_nil
45
45
  end
46
46
 
47
+ context "when pages in resource map but no wiki_pages" do
48
+ before(:each) do
49
+ @converter = CanvasLinkMigrator::ImportedHtmlConverter.new(resource_map: JSON.parse(File.read("spec/fixtures/canvas_resource_map_pages.json")))
50
+ end
51
+
52
+ it "converts a wiki reference with migration id" do
53
+ test_string = %(<a href="%24WIKI_REFERENCE%24/pages/A?query=blah">Test Wiki Page</a>)
54
+ html, bad_links = @converter.convert_exported_html(test_string)
55
+ expect(html).to eq %(<a href="#{@path}pages/slug-a?query=blah">Test Wiki Page</a>)
56
+ expect(bad_links).to be_nil
57
+ end
58
+
59
+ it "converts a wiki reference by migration id" do
60
+ test_string = %(<a href="wiki_page_migration_id=A">Test Wiki Page</a>)
61
+ expect(@converter.convert_exported_html(test_string)).to eq([%(<a href="#{@path}pages/slug-a">Test Wiki Page</a>), nil])
62
+ end
63
+ end
64
+
47
65
  context "when course attachments exist" do
48
66
  subject { @converter.convert_exported_html(test_string) }
49
67
 
@@ -33,6 +33,12 @@ describe CanvasLinkMigrator::LinkResolver do
33
33
  expect(link[:new_value]).to eq("/courses/2/pages/slug-a?foo=bar")
34
34
  end
35
35
 
36
+ it "converts wiki_pages links with pages in resource map" do
37
+ link = { link_type: :wiki_page, migration_id: "A", query: "?foo=bar" }
38
+ resolver(JSON.parse(File.read("spec/fixtures/canvas_resource_map_pages.json"))).resolve_link!(link)
39
+ expect(link[:new_value]).to eq("/courses/2/pages/slug-a?foo=bar")
40
+ end
41
+
36
42
  it "converts module_item links" do
37
43
  link = { link_type: :module_item, migration_id: "C", query: "?foo=bar" }
38
44
  resolver.resolve_link!(link)
@@ -0,0 +1,134 @@
1
+ {
2
+ "attachment_path_id_lookup": {
3
+ "subfolder/test.png": "G",
4
+ "subfolder/with a space/test.png": "F",
5
+ "subfolder/with a space/yodawg.mov": "I",
6
+ "subfolder/withCapital/test.png": "migration_id!",
7
+ "lolcat.mp3": "H",
8
+ "test.png": "E"
9
+ },
10
+ "contains_migration_ids": true,
11
+ "destination_course": "2",
12
+ "destination_hosts": [
13
+ "apple.edu",
14
+ "kiwi.edu"
15
+ ],
16
+ "destination_root_folder": "course files/",
17
+ "resource_mapping": {
18
+ "announcements": {
19
+ "H": {
20
+ "source": {
21
+ "id": "9"
22
+ },
23
+ "destination": {
24
+ "id": "10"
25
+ }
26
+ }
27
+ },
28
+ "assignments": {
29
+ "I": {
30
+ "source": {
31
+ "id": "11"
32
+ },
33
+ "destination": {
34
+ "id": "12"
35
+ }
36
+ }
37
+ },
38
+ "discussion_topics": {
39
+ "G": {
40
+ "destination": {
41
+ "id": "7"
42
+ },
43
+ "source": {
44
+ "id": "6"
45
+ }
46
+ }
47
+ },
48
+ "files": {
49
+ "E": {
50
+ "destination": {
51
+ "id": "5",
52
+ "media_entry_id": "m-stuff"
53
+ },
54
+ "source": {
55
+ "id": "3",
56
+ "media_entry_id": "m-stuff"
57
+ }
58
+ },
59
+ "F": {
60
+ "destination": {
61
+ "id": "6",
62
+ "media_entry_id": "m-stuff"
63
+ },
64
+ "source": {
65
+ "id": "4",
66
+ "media_entry_id": "m-stuff"
67
+ }
68
+ },
69
+ "G": {
70
+ "destination": {
71
+ "id": "7"
72
+ },
73
+ "source": {
74
+ "id": "2"
75
+ }
76
+ },
77
+ "H": {
78
+ "destination": {
79
+ "id": "8",
80
+ "media_entry_id": "m-lolcat"
81
+ },
82
+ "source": {
83
+ "id": "3",
84
+ "media_entry_id": "m-lolcat"
85
+ }
86
+ },
87
+ "I": {
88
+ "destination": {
89
+ "id": "9",
90
+ "media_entry_id": "m-yodawg"
91
+ },
92
+ "source": {
93
+ "id": "4",
94
+ "media_entry_id": "m-yodawg"
95
+ }
96
+ }
97
+ },
98
+ "module_items": {
99
+ "C": {
100
+ "destination": {
101
+ "id": "3"
102
+ },
103
+ "source": {
104
+ "id": "2"
105
+ }
106
+ }
107
+ },
108
+ "modules": {
109
+ "J": {
110
+ "destination": {
111
+ "id": "36"
112
+ },
113
+ "source": {
114
+ "id": "22"
115
+ }
116
+ }
117
+ },
118
+ "pages": {
119
+ "A": {
120
+ "destination": {
121
+ "id": "2",
122
+ "url": "slug-a"
123
+ },
124
+ "source": {
125
+ "id": "1",
126
+ "url": "slug-a"
127
+ }
128
+ }
129
+ }
130
+ },
131
+ "source_course": "1",
132
+ "source_host": "pineapple.edu"
133
+ }
134
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_link_migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mysti Lilla
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-01-29 00:00:00.000000000 Z
14
+ date: 2024-02-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -147,6 +147,7 @@ files:
147
147
  - spec/canvas_link_migrator/link_resolver_spec.rb
148
148
  - spec/canvas_link_migrator_spec.rb
149
149
  - spec/fixtures/canvas_resource_map.json
150
+ - spec/fixtures/canvas_resource_map_pages.json
150
151
  - spec/spec_helper.rb
151
152
  - test.sh
152
153
  homepage: