|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'authors index', type: :feature, js: true do |
| 4 | + |
| 5 | + before do |
| 6 | + Author.create!(name: 'John', last_name: 'Doe') |
| 7 | + Author.create!(name: 'Jane', last_name: 'Roe') |
| 8 | + end |
| 9 | + |
| 10 | + before do |
| 11 | + add_author_resource |
| 12 | + end |
| 13 | + |
| 14 | + before do |
| 15 | + visit '/admin/authors' |
| 16 | + end |
| 17 | + |
| 18 | + context 'show scoped collection action in sidebar' do |
| 19 | + |
| 20 | + it 'page has collection_actions_sidebar_section' do |
| 21 | + expect(page.find('#collection_actions_sidebar_section')) |
| 22 | + .to have_css('h3', text: 'Collection Actions') |
| 23 | + expect(page.find('#collection_actions_sidebar_section')) |
| 24 | + .to have_css('button', text: 'Update') |
| 25 | + expect(page.find('#collection_actions_sidebar_section')) |
| 26 | + .to have_css('button', text: 'Delete') |
| 27 | + end |
| 28 | + |
| 29 | + end |
| 30 | + |
| 31 | + |
| 32 | + context 'scoped collection action UPDATE' do |
| 33 | + before do |
| 34 | + @today = Date.today |
| 35 | + |
| 36 | + page.find('#collection_actions_sidebar_section button', text: 'Update').click |
| 37 | + page.within ('body>.active_admin_dialog_mass_update_by_filter') do |
| 38 | + page.find('input#mass_update_dialog_birthday').click |
| 39 | + page.find('input[name="birthday"]').click |
| 40 | + end |
| 41 | + page.find('.ui-datepicker .ui-datepicker-days-cell-over.ui-datepicker-today', visible: true).click |
| 42 | + page.within ('body>.active_admin_dialog_mass_update_by_filter') do |
| 43 | + page.find('button', text: 'OK').click |
| 44 | + end |
| 45 | + end |
| 46 | + |
| 47 | + it 'new birthday was set for all authors' do |
| 48 | + expect(page).to have_css('.flashes .flash.flash_notice') |
| 49 | + expect(Author.all.map(&:birthday).uniq.count).to eq(1) |
| 50 | + expect(Author.take.birthday).to eq(@today) |
| 51 | + end |
| 52 | + end |
| 53 | + |
| 54 | + |
| 55 | + context 'scoped collection action DELETE' do |
| 56 | + before do |
| 57 | + page.find('#collection_actions_sidebar_section button', text: 'Delete').click |
| 58 | + end |
| 59 | + |
| 60 | + context 'title' do |
| 61 | + it 'has predefined confirmation title' do |
| 62 | + expect(page).to have_css('.active_admin_dialog_mass_update_by_filter', text: 'Delete all?') |
| 63 | + end |
| 64 | + end |
| 65 | + |
| 66 | + context 'action' do |
| 67 | + before do |
| 68 | + page.within ('body>.active_admin_dialog_mass_update_by_filter') do |
| 69 | + page.find('button', text: 'OK').click |
| 70 | + end |
| 71 | + end |
| 72 | + |
| 73 | + it 'delete all authors' do |
| 74 | + expect(page).to have_css('.flashes .flash.flash_notice') |
| 75 | + expect(Author.count).to eq(0) |
| 76 | + end |
| 77 | + end |
| 78 | + end |
| 79 | + |
| 80 | + |
| 81 | + context |
| 82 | + |
| 83 | +end |
0 commit comments