|
6 | 6 | let(:book_uuid) { SecureRandom.uuid }
|
7 | 7 | let(:page_uuid) { 'a9ce0e38-4f52-4fe0-9433-d8df95f6e3b2' }
|
8 | 8 |
|
9 |
| - let(:expected_pre_tag) { "assessment:preparedness:https://openstax.org/orn/book:page/#{book_uuid}:#{page_uuid}" } |
10 |
| - let(:expected_post_tag) { "assessment:practice:https://openstax.org/orn/book:page/#{book_uuid}:#{page_uuid}" } |
| 9 | + let(:expected_pre_tag) { "assessment:preparedness:https://openstax.org/orn/book:page/#{book_uuid}:#{page_uuid}" } |
| 10 | + let(:expected_post_tag) { "assessment:practice:https://openstax.org/orn/book:page/#{book_uuid}:#{page_uuid}" } |
| 11 | + let(:expected_cnxmod_tag) { "context-cnxmod:#{page_uuid}" } |
11 | 12 |
|
12 | 13 | let!(:exercises) { (1..9).map { |ii| FactoryBot.create(:publication, number: ii).publishable } }
|
13 | 14 |
|
14 | 15 | # Disable set_slug_tags!
|
15 | 16 | before { allow_any_instance_of(Exercise).to receive(:set_slug_tags!) }
|
16 | 17 |
|
17 | 18 | it 'tags exercises with the sample spreadsheet' do
|
18 |
| - expect { described_class.call(filename: fixture_path, book_uuid: book_uuid) }.to change { ExerciseTag.count }.by(10) |
| 19 | + expect do |
| 20 | + described_class.call(filename: fixture_path, book_uuid: book_uuid) |
| 21 | + end.to change { ExerciseTag.count }.by(15) |
19 | 22 |
|
20 | 23 | exercises.each(&:reload)
|
21 | 24 |
|
22 | 25 | exercises.each do |exercise|
|
23 | 26 | valid_tags = []
|
24 | 27 | valid_tags << expected_pre_tag if exercise.number <= 5
|
25 |
| - valid_tags << expected_post_tag if exercise.number >= 5 |
| 28 | + valid_tags << [expected_post_tag, expected_cnxmod_tag] if exercise.number >= 5 |
26 | 29 |
|
27 | 30 | expect(exercise.tags).to satisfy do |tags|
|
28 |
| - expect(tags.length).to eq exercise.number == 5 ? 2 : 1 |
| 31 | + expect(tags.length).to eq exercise.number < 5 ? 1 : exercise.number == 5 ? 3 : 2 |
29 | 32 | tags.all { |tag| expect(valid_tags).to include tag.name }
|
30 | 33 | end
|
31 | 34 | end
|
32 | 35 | end
|
33 | 36 |
|
34 | 37 | it 'skips exercises with no changes (idempotence)' do
|
35 |
| - expect { described_class.call(filename: fixture_path, book_uuid: book_uuid) }.to change { ExerciseTag.count }.by(10) |
| 38 | + expect do |
| 39 | + described_class.call(filename: fixture_path, book_uuid: book_uuid) |
| 40 | + end.to change { ExerciseTag.count }.by(15) |
36 | 41 |
|
37 | 42 | expect { described_class.call(filename: fixture_path, book_uuid: book_uuid) }.not_to change { ExerciseTag.count }
|
38 | 43 | end
|
|
0 commit comments