|
92 | 92 | expect(page).to have_css('#q_created_at_lteq_datetime_picker[placeholder=To]')
|
93 | 93 | end
|
94 | 94 | end
|
| 95 | + |
| 96 | + context 'filter by virtual attribute last_seen_at - without column&type properties (search by updated_at)' do |
| 97 | + let!(:first_author) { Author.create!(name: 'Ren', last_name: 'current', updated_at: Time.now.to_s(:db)) } |
| 98 | + let!(:second_author) { Author.create!(name: 'Rey', last_name: 'future', updated_at: 21.days.from_now.to_s(:db)) } |
| 99 | + |
| 100 | + before do |
| 101 | + # chose 01 and 20 day of the current month |
| 102 | + page.find('input#q_last_seen_at_gteq_datetime_picker').click |
| 103 | + page.find('.xdsoft_datetimepicker', visible: true) |
| 104 | + .find('.xdsoft_calendar td.xdsoft_date[data-date="1"]').click |
| 105 | + page.find('.xdsoft_datetimepicker', visible: true) |
| 106 | + .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 107 | + |
| 108 | + page.find('input#q_last_seen_at_lteq_datetime_picker').click |
| 109 | + page.find('.xdsoft_datetimepicker', visible: true) |
| 110 | + .find('.xdsoft_calendar td.xdsoft_date[data-date="20"]').click |
| 111 | + page.find('.xdsoft_datetimepicker', visible: true) |
| 112 | + .find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click |
| 113 | + |
| 114 | + @value_from = page.find('#q_last_seen_at_gteq_datetime_picker').value |
| 115 | + @value_to = page.find('#q_last_seen_at_lteq_datetime_picker').value |
| 116 | + |
| 117 | + page.find('#sidebar input[type=submit]').click |
| 118 | + page.has_css?('h4', text: 'Current filters:') |
| 119 | + end |
| 120 | + |
| 121 | + it 'should filter records properly' do |
| 122 | + expect(page).to have_text(first_author.name) |
| 123 | + expect(page).not_to have_text(second_author.name) |
| 124 | + end |
| 125 | + |
| 126 | + it 'input#value and placeholder is the same as before form submit' do |
| 127 | + # last_seen_at (without typecasting just a string) should contain Hours:Minutes, as selected before submit |
| 128 | + expect(page.find('#q_last_seen_at_gteq_datetime_picker').value).to match(@value_from) |
| 129 | + expect(page.find('#q_last_seen_at_lteq_datetime_picker').value).to match(@value_to) |
| 130 | + |
| 131 | + expect(page).to have_css('#q_last_seen_at_gteq_datetime_picker[placeholder=From]') |
| 132 | + expect(page).to have_css('#q_last_seen_at_lteq_datetime_picker[placeholder=To]') |
| 133 | + end |
| 134 | + end |
95 | 135 | end
|
96 | 136 | end
|
0 commit comments