@@ -55,8 +55,7 @@ def attachment_in_course(course)
5555 data = { 'name' => "Hi" , 'question_text' => "Translate this: <img src='/courses/#{ @course . id } /files/#{ @attachment . id } /download'>" , 'answers' => [ { 'id' => 1 } , { 'id' => 2 } ] }
5656 @question = @bank . assessment_questions . create! ( :question_data => data )
5757
58- expect ( @attachment . reload . cloned_item . attachments . length ) . to eq 2
59- @clone = @attachment . cloned_item . attachments . last
58+ @clone = @question . attachments . where ( root_attachment : @attachment ) . first
6059
6160 expect ( @question . reload . question_data [ 'question_text' ] ) . to eq "Translate this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } '>"
6261 end
@@ -66,8 +65,7 @@ def attachment_in_course(course)
6665 data = { 'name' => "Hi" , 'question_text' => "Translate this: <img src='/courses/#{ @course . id } /file_contents/course%20files/unfiled/test.jpg'>" , 'answers' => [ { 'id' => 1 } , { 'id' => 2 } ] }
6766 @question = @bank . assessment_questions . create! ( :question_data => data )
6867
69- expect ( @attachment . reload . cloned_item . attachments . length ) . to eq 2
70- @clone = @attachment . cloned_item . attachments . last
68+ @clone = @question . attachments . where ( root_attachment : @attachment ) . first
7169
7270 expect ( @question . reload . question_data [ 'question_text' ] ) . to eq "Translate this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } '>"
7371 end
@@ -79,8 +77,7 @@ def attachment_in_course(course)
7977 'answers' => [ { 'id' => 1 } , { 'id' => 2 } ] }
8078 @question = @bank . assessment_questions . create! ( :question_data => data )
8179
82- expect ( @attachment . reload . cloned_item . attachments . length ) . to eq 2
83- @clone = @attachment . cloned_item . attachments . last
80+ @clone = @question . attachments . where ( root_attachment : @attachment ) . first
8481
8582 expect ( @question . reload . question_data [ 'question_text' ] ) . to eq "Translate this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } &wrap=1'> and this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } &wrap=1'>"
8683 end
@@ -91,8 +88,7 @@ def attachment_in_course(course)
9188 data = { 'name' => "Hi" , 'question_text' => "Translate this: <img src='/courses/#{ @course . id } /files/#{ @attachment . id } /download'> and this: <img src='/courses/#{ @course . id } /file_contents/course%20files/unfiled/test.jpg'>" , 'answers' => [ { 'id' => 1 } , { 'id' => 2 } ] }
9289 @question = @bank . assessment_questions . create! ( :question_data => data )
9390
94- expect ( @attachment . reload . cloned_item . attachments . length ) . to eq 2
95- @clone = @attachment . cloned_item . attachments . last
91+ @clone = @question . attachments . where ( root_attachment : @attachment ) . first
9692
9793 expect ( @question . reload . question_data [ 'question_text' ] ) . to eq "Translate this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } '> and this: <img src='/assessment_questions/#{ @question . id } /files/#{ @clone . id } /download?verifier=#{ @clone . uuid } '>"
9894 end
@@ -129,8 +125,7 @@ def attachment_in_course(course)
129125
130126 @question = @bank . assessment_questions . create! ( :question_data => data )
131127
132- @attachments . each { |k , ary | ary . each { |a | a . reload ; expect ( a . cloned_item . attachments . length ) . to eq 2 } }
133- @attachment_clones = Hash [ @attachments . map { |k , ary | [ k , ary . map { |a | a . cloned_item . attachments . last } ] } ]
128+ @attachment_clones = Hash [ @attachments . map { |k , ary | [ k , ary . map { |a | @question . attachments . where ( root_attachment_id : a ) . first } ] } ]
134129
135130 @attachment_clones . each do |key , ary |
136131 string = eval "@question.question_data#{ key } "
0 commit comments