Merge pull request #2255 from internetee/2253-add-account_activitiy-tests

Added missing integration/system tests for account_activities
This commit is contained in:
Timo Võhmar 2021-12-29 17:09:59 +02:00 committed by GitHub
commit 0538125998
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 1 deletions

View file

@ -3,3 +3,31 @@ one:
invoice: one
bank_transaction: one
created_at: <%= Time.zone.parse('2010-07-05 10:00') %>
renew_cash:
account: cash
activity_type: "renew"
description: "Description of activity renew_cash"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-08-05 10:00') %>
renew_two:
account: two
activity_type: "renew"
description: "Description of activity renew_two"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-12-05 10:00') %>
create_two:
account: two
activity_type: "create"
description: "Description of activity create_two"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-09-05 10:00') %>
renew_two_previous:
account: two
activity_type: "renew"
description: "Description of activity renew_two_previous"
sum: "123.00"
created_at: <%= Time.zone.parse('2021-10-05 10:00') %>

View file

@ -36,4 +36,28 @@ class AdminAreaAccountActivitiesIntegrationTest < ApplicationSystemTestCase
response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_search_account_activity
account_activities(:one).update(description: "Description of activity one",
sum: "123.00",
activity_type: "create",
created_at: Time.zone.parse('2021-07-05 10:00'))
get admin_account_activities_path, params: { q: { account_registrar_id_in: [registrars(:bestnames).id, registrars(:goodnames).id],
activity_type_in: ['renew'],
created_at_gteq: '2021-09-25',
created_at_lteq: '2021-11-' },
results_per_page: 1,
page: 2 }
assert_response :success
parsed_data = Nokogiri::HTML.parse(response.body)
tr = parsed_data.xpath('//*/table/tbody/tr')
assert_equal tr.count, 1
assert_includes tr.xpath("//td").text, account_activities(:renew_two).description
assert_equal tr.xpath("//td").first.at('a').text, registrars(:goodnames).code
end
end

View file

@ -25,4 +25,20 @@ class RegistrarAccountActivitiesTest < ApplicationSystemTestCase
response.headers['Content-Disposition']
assert_not_empty response.body
end
end
def test_search_account_activity_with_invalid_date
account_activities(:one).update(description: "Description of activity one",
sum: "123.00",
activity_type: "create",
created_at: Time.zone.parse('2021-07-05 10:00'))
visit registrar_account_activities_path
find('#q_activity_type_in').click
find(:option, "Renew").select_option
fill_in('q_created_at_lteq', with: '2021-12--')
find(:xpath, ".//button[./span[contains(@class, 'glyphicon-search')]]").click
assert_text 'Description of activity renew_cash'
end
end