|
51 | 51 | end |
52 | 52 | end |
53 | 53 | end |
| 54 | + |
| 55 | + context 'when the supplier has frameworks in different states' do |
| 56 | + let!(:supplier) { FactoryBot.create(:supplier, name: 'Second Supplier') } |
| 57 | + let!(:published_framework) { FactoryBot.create(:framework, name: 'Published Framework', aasm_state: 'published') } |
| 58 | + let!(:new_framework) { FactoryBot.create(:framework, name: 'New Framework', aasm_state: 'new') } |
| 59 | + let!(:archived_framework) { FactoryBot.create(:framework, name: 'Archived Framework', aasm_state: 'archived') } |
| 60 | + |
| 61 | + before do |
| 62 | + stub_govuk_bank_holidays_request |
| 63 | + |
| 64 | + FactoryBot.create(:agreement, framework: published_framework, supplier: supplier) |
| 65 | + FactoryBot.create(:agreement, framework: new_framework, supplier: supplier) |
| 66 | + FactoryBot.create(:agreement, framework: archived_framework, supplier: supplier) |
| 67 | + |
| 68 | + sign_in_as_admin |
| 69 | + end |
| 70 | + |
| 71 | + scenario 'frameworks are filtered to only show active ones' do |
| 72 | + visit new_admin_supplier_task_path(supplier) |
| 73 | + |
| 74 | + expect(page).to have_select('Framework', options: [published_framework.full_name, new_framework.full_name]) |
| 75 | + expect(page).not_to have_select('Framework', options: [archived_framework.full_name]) |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + context 'when the supplier has only archived frameworks' do |
| 80 | + before do |
| 81 | + stub_govuk_bank_holidays_request |
| 82 | + supplier = FactoryBot.create(:supplier, name: 'Archived Only Supplier') |
| 83 | + archived_framework = FactoryBot.create(:framework, name: 'Archived Framework', aasm_state: 'archived') |
| 84 | + FactoryBot.create(:agreement, framework: archived_framework, supplier: supplier) |
| 85 | + sign_in_as_admin |
| 86 | + end |
| 87 | + |
| 88 | + scenario 'does not show add missing task link' do |
| 89 | + visit admin_suppliers_path |
| 90 | + click_on 'Archived Only Supplier' |
| 91 | + expect(page).not_to have_link 'Add a missing task' |
| 92 | + end |
| 93 | + end |
54 | 94 | end |
0 commit comments