|
15 | 15 | sign_out
|
16 | 16 | end
|
17 | 17 |
|
18 |
| - it 'add a currency conversion', feature: true do |
19 |
| - visit admin_conference_currency_conversions_path(conference.short_title) |
20 |
| - click_link 'Add Currency Conversion' |
21 |
| - |
22 |
| - fill_in 'currency_conversion_from_currency', with: 'USD' |
23 |
| - fill_in 'currency_conversion_to_currency', with: 'EUR' |
24 |
| - fill_in 'currency_conversion_rate', with: '0.89' |
| 18 | + context 'for a conference with no tickets' do |
| 19 | + before do |
| 20 | + conference.currency_conversions << create(:currency_conversion) |
| 21 | + conference.tickets.destroy_all |
| 22 | + end |
25 | 23 |
|
26 |
| - click_button 'Create Currency conversion' |
27 |
| - page.find('#flash') |
28 |
| - expect(flash).to eq('Currency conversion was successfully created.') |
29 |
| - within('table#currency-conversions') do |
30 |
| - expect(page.has_content?('USD')).to be true |
31 |
| - expect(page.has_content?('EUR')).to be true |
32 |
| - expect(page.has_content?('0.89')).to be true |
33 |
| - expect(page.assert_selector('tbody tr', count: 1)).to be true |
| 24 | + it 'show error message when adding new currency conversion', feature: true, js: true do |
| 25 | + visit admin_conference_currency_conversions_path(conference.short_title) |
| 26 | + click_link 'Add Currency Conversion' |
| 27 | + page.find('#flash') |
| 28 | + expect(flash).to eq('No tickets available for this conference. Cannot create or edit currency conversions.') |
34 | 29 | end
|
35 |
| - end |
36 | 30 |
|
37 |
| - it 'edit a currency conversion', feature: true do |
38 |
| - conference.currency_conversions << create(:currency_conversion) |
39 |
| - visit admin_conference_currency_conversions_path(conference.short_title) |
40 |
| - within('table tbody tr:nth-of-type(1) td:nth-of-type(4)') do |
41 |
| - click_link 'Edit' |
| 31 | + it 'show error message when editing a currency conversion', feature: true, js: true do |
| 32 | + visit admin_conference_currency_conversions_path(conference.short_title) |
| 33 | + within('table tbody tr:nth-of-type(1) td:nth-of-type(4)') do |
| 34 | + click_link 'Edit' |
| 35 | + end |
| 36 | + page.find('#flash') |
| 37 | + expect(flash).to eq('No tickets available for this conference. Cannot create or edit currency conversions.') |
42 | 38 | end
|
43 |
| - fill_in 'currency_conversion_from_currency', with: 'USD' |
44 |
| - fill_in 'currency_conversion_to_currency', with: 'RMB' |
45 |
| - fill_in 'currency_conversion_rate', with: '6.9' |
46 |
| - click_button 'Update Currency conversion' |
47 |
| - page.find('#flash') |
48 |
| - expect(flash).to eq('Currency conversion was successfully updated.') |
49 |
| - within('table#currency-conversions') do |
50 |
| - expect(page.has_content?('USD')).to be true |
51 |
| - expect(page.has_content?('RMB')).to be true |
52 |
| - expect(page.has_content?('6.9')).to be true |
53 |
| - expect(page.assert_selector('tbody tr', count: 1)).to be true |
| 39 | + |
| 40 | + it 'does not show error message when deleting a currency conversion', feature: true, js: true do |
| 41 | + visit admin_conference_currency_conversions_path(conference.short_title) |
| 42 | + page.accept_alert do |
| 43 | + within('table tbody tr:nth-of-type(1) td:nth-of-type(4)') do |
| 44 | + click_link 'Delete' |
| 45 | + end |
| 46 | + end |
| 47 | + page.find('#flash') |
| 48 | + expect(flash).to eq('Currency conversion was successfully deleted.') |
| 49 | + within('table#currency-conversions') do |
| 50 | + expect(page.assert_selector('tbody tr', count: 0)).to be true |
| 51 | + end |
54 | 52 | end
|
55 | 53 | end
|
56 | 54 |
|
57 |
| - it 'Deletes Currency Conversion', feature: true, js: true do |
58 |
| - conference.currency_conversions << create(:currency_conversion) |
59 |
| - visit admin_conference_currency_conversions_path(conference.short_title) |
60 |
| - # Remove currency conversion |
61 |
| - page.accept_alert do |
| 55 | + context 'for a conference with tickets' do |
| 56 | + it 'add a currency conversion', feature: true, js: true do |
| 57 | + visit admin_conference_currency_conversions_path(conference.short_title) |
| 58 | + click_link 'Add Currency Conversion' |
| 59 | + select 'EUR', from: 'currency_conversion_to_currency' |
| 60 | + fill_in 'currency_conversion_rate', with: '0.89' |
| 61 | + click_button 'Create Currency conversion' |
| 62 | + page.find('#flash') |
| 63 | + expect(flash).to eq('Currency conversion was successfully created.') |
| 64 | + within('table#currency-conversions') do |
| 65 | + expect(page.has_content?('USD')).to be true |
| 66 | + expect(page.has_content?('EUR')).to be true |
| 67 | + expect(page.has_content?('0.89')).to be true |
| 68 | + expect(page.assert_selector('tbody tr', count: 1)).to be true |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + it 'edit a currency conversion', feature: true, js: true do |
| 73 | + conference.currency_conversions << create(:currency_conversion) |
| 74 | + visit admin_conference_currency_conversions_path(conference.short_title) |
62 | 75 | within('table tbody tr:nth-of-type(1) td:nth-of-type(4)') do
|
63 |
| - click_link 'Delete' |
| 76 | + click_link 'Edit' |
| 77 | + end |
| 78 | + select 'JPY', from: 'currency_conversion_to_currency' |
| 79 | + fill_in 'currency_conversion_rate', with: '6.9' |
| 80 | + click_button 'Update Currency conversion' |
| 81 | + page.find('#flash') |
| 82 | + expect(flash).to eq('Currency conversion was successfully updated.') |
| 83 | + within('table#currency-conversions') do |
| 84 | + expect(page.has_content?('USD')).to be true |
| 85 | + expect(page.has_content?('JPY')).to be true |
| 86 | + expect(page.has_content?('6.9')).to be true |
| 87 | + expect(page.assert_selector('tbody tr', count: 1)).to be true |
64 | 88 | end
|
65 | 89 | end
|
66 |
| - page.find('#flash') |
67 | 90 |
|
68 |
| - # Validations |
69 |
| - expect(flash).to eq('Currency conversion was successfully deleted.') |
70 |
| - within('table#currency-conversions') do |
71 |
| - expect(page.assert_selector('tbody tr', count: 0)).to be true |
| 91 | + it 'Deletes Currency Conversion', feature: true, js: true do |
| 92 | + conference.currency_conversions << create(:currency_conversion) |
| 93 | + visit admin_conference_currency_conversions_path(conference.short_title) |
| 94 | + # Remove currency conversion |
| 95 | + page.accept_alert do |
| 96 | + within('table tbody tr:nth-of-type(1) td:nth-of-type(4)') do |
| 97 | + click_link 'Delete' |
| 98 | + end |
| 99 | + end |
| 100 | + page.find('#flash') |
| 101 | + |
| 102 | + # Validations |
| 103 | + expect(flash).to eq('Currency conversion was successfully deleted.') |
| 104 | + within('table#currency-conversions') do |
| 105 | + expect(page.assert_selector('tbody tr', count: 0)).to be true |
| 106 | + end |
72 | 107 | end
|
73 | 108 | end
|
74 | 109 | end
|
|
0 commit comments