|
50 | 50 | context 'when no auto-remediated work version exists after the one being remediated' do |
51 | 51 | context 'when no remaining remediation jobs' do |
52 | 52 | it 'builds a new work version, attaches the remediated file, and publishes' do |
53 | | - allow(Down).to receive(:download).with(remediated_url).and_return(Tempfile.new('remediated')) |
| 53 | + allow(Down).to receive(:download).with(remediated_url).and_return(Tempfile.new('COMPLIANT')) |
54 | 54 | wv_count_before = WorkVersion.count |
55 | 55 |
|
56 | 56 | result = described_class.call(file_resource, remediated_url) |
57 | 57 | expect(WorkVersion.count).to eq(wv_count_before + 1) |
58 | 58 | expect(FileResource).to exist(file_resource.id) |
59 | 59 | expect(FileVersionMembership.find_by(work_version: result, file_resource: file_resource)).to be_nil |
60 | | - expect(WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true).count).to eq(1) |
| 60 | + remediated_file_resource = WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true) |
| 61 | + expect(remediated_file_resource.count).to eq(1) |
| 62 | + expect(remediated_file_resource.first.file_data['metadata']['filename']).to eq( |
| 63 | + "ACCESSIBLE_VERSION_#{FileResource.find(file_resource.id).file_data['metadata']['filename']}" |
| 64 | + ) |
61 | 65 | expect(result.external_app).to eq(ExternalApp.pdf_accessibility_api) |
62 | 66 | expect(result).to be_published |
63 | 67 | expect(AutoRemediationNotifications) |
|
88 | 92 | expect(WorkVersion.count).to eq(wv_count_before + 1) |
89 | 93 | expect(FileResource).to exist(file_resource.id) |
90 | 94 | expect(FileVersionMembership.find_by(work_version: result, file_resource: file_resource)).to be_nil |
91 | | - expect(WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true).count).to eq(1) |
| 95 | + remediated_file_resource = WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true) |
| 96 | + expect(remediated_file_resource.count).to eq(1) |
| 97 | + expect(remediated_file_resource.first.file_data['metadata']['filename']).to eq( |
| 98 | + "ACCESSIBLE_VERSION_#{FileResource.find(file_resource.id).file_data['metadata']['filename']}" |
| 99 | + ) |
92 | 100 | expect(result.external_app).to eq(ExternalApp.pdf_accessibility_api) |
93 | 101 | expect(result).to be_draft |
94 | 102 | expect(AutoRemediationNotifications) |
|
122 | 130 | expect(WorkVersion.count).to eq(wv_count_before) |
123 | 131 | expect(FileResource).to exist(file_resource.id) |
124 | 132 | expect(FileVersionMembership.find_by(work_version: result, file_resource: file_resource)).to be_nil |
125 | | - expect(WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true).count).to eq(1) |
| 133 | + remediated_file_resource = WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true) |
| 134 | + expect(remediated_file_resource.count).to eq(1) |
| 135 | + expect(remediated_file_resource.first.file_data['metadata']['filename']).to eq( |
| 136 | + "ACCESSIBLE_VERSION_#{FileResource.find(file_resource.id).file_data['metadata']['filename']}" |
| 137 | + ) |
126 | 138 | expect(result.external_app).to eq(ExternalApp.pdf_accessibility_api) |
127 | 139 | expect(result).to be_published |
128 | 140 | expect(AutoRemediationNotifications) |
|
153 | 165 | expect(WorkVersion.count).to eq(wv_count_before) |
154 | 166 | expect(FileResource).to exist(file_resource.id) |
155 | 167 | expect(FileVersionMembership.find_by(work_version: result, file_resource: file_resource)).to be_nil |
156 | | - expect(WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true).count).to eq(1) |
| 168 | + remediated_file_resource = WorkVersion.find(result.id).file_resources.where(auto_remediated_version: true) |
| 169 | + expect(remediated_file_resource.count).to eq(1) |
| 170 | + expect(remediated_file_resource.first.file_data['metadata']['filename']).to eq( |
| 171 | + "ACCESSIBLE_VERSION_#{FileResource.find(file_resource.id).file_data['metadata']['filename']}" |
| 172 | + ) |
157 | 173 | expect(result.external_app).to eq(ExternalApp.pdf_accessibility_api) |
158 | 174 | expect(result).to be_draft |
159 | 175 | expect(AutoRemediationNotifications) |
|
0 commit comments