|
31 | 31 | expect(page).to have_table(resource_name: 'Business Employees') |
32 | 32 | within_table_for do |
33 | 33 | expect(page).to have_table_row(count: 2) |
34 | | - # 2x id, full_name, salary, common_duties, extra_duties, created_at, updated_at, actions |
35 | | - expect(page).to have_table_cell(count: 16) |
| 34 | + # 2x9 (id, selectable, full_name, salary, common_duties, extra_duties, created_at, updated_at, actions) |
| 35 | + expect(page).to have_table_cell(count: 18) |
36 | 36 |
|
37 | 37 | expect(page).to have_table_cell(text: 'John Doe') |
38 | 38 | expect(page).to have_table_cell(text: 'John Doe', column: 'Full Name') |
39 | 39 | expect(page).to_not have_table_cell(text: 'John Doe', column: 'Id') |
40 | 40 |
|
41 | 41 | within_table_row(id: john.id) do |
42 | | - expect(page).to have_table_cell(count: 8) |
| 42 | + expect(page).to have_table_cell(count: 9) |
43 | 43 | expect(page).to have_table_cell(text: 'John Doe') |
44 | 44 | expect(page).to have_table_cell(text: 'John Doe', column: 'Full Name') |
45 | 45 | expect(page).to have_table_cell(text: '$100.00', column: 'Salary') |
|
49 | 49 | end |
50 | 50 |
|
51 | 51 | within_table_row(id: jane.id) do |
52 | | - expect(page).to have_table_cell(count: 8) |
| 52 | + expect(page).to have_table_cell(count: 9) |
53 | 53 | expect(page).to have_table_cell(text: jane.id, column: 'Id') |
54 | 54 | expect(page).to have_table_cell(text: 'Jane Air', column: 'Full Name') |
55 | 55 | expect(page).to have_table_cell(exact_text: '$101.00', column: 'Salary') |
|
59 | 59 | expect(page).to_not have_table_cell(text: 'John Doe', column: 'Full Name') |
60 | 60 | end |
61 | 61 | end |
62 | | - # take_screenshot |
| 62 | + end |
| 63 | + |
| 64 | + it 'updates salary via batch action' do |
| 65 | + john = Billing::Employee.create!(full_name: 'John Doe', salary: 100) |
| 66 | + jane = Billing::Employee.create!(full_name: 'Jane Air', salary: 101) |
| 67 | + 5.times { |i| Billing::Employee.create!(full_name: "Jack #{i}", salary: 10) } |
| 68 | + |
| 69 | + subject |
| 70 | + |
| 71 | + within_table_for do |
| 72 | + select_table_row(id: john.id) |
| 73 | + select_table_row(id: jane.id) |
| 74 | + end |
| 75 | + |
| 76 | + open_batch_action_menu |
| 77 | + expect(page).to have_batch_action('Update Salary Selected', exact: true) |
| 78 | + expect(page).to have_batch_action('Delete Selected', exact: true) |
| 79 | + |
| 80 | + click_batch_action('Update Salary Selected', exact: true) |
| 81 | + within_modal_dialog do |
| 82 | + fill_in 'salary', with: '200.35' |
| 83 | + end |
| 84 | + confirm_modal_dialog |
| 85 | + |
| 86 | + expect(page).to have_flash_message('Salary was updated successfully', exact: true) |
| 87 | + |
| 88 | + expect(john.reload.salary).to eq 200.35 |
| 89 | + expect(jane.reload.salary).to eq 200.35 |
63 | 90 | end |
64 | 91 | end |
0 commit comments