@ -126,7 +126,8 @@ RSpec.describe "User Features" do
context " when viewing lettings logs for specific organisation " do
let ( :first_log ) { organisation . lettings_logs . first }
let! ( :log_to_search ) { FactoryBot . create ( :lettings_log , created_by : user ) }
let! ( :other_logs ) { FactoryBot . create_list ( :lettings_log , 4 , created_by : user ) }
let! ( :other_general_needs_logs ) { FactoryBot . create_list ( :lettings_log , 4 , created_by : user , needstype : 1 ) }
let! ( :other_supported_housing_logs ) { FactoryBot . create_list ( :lettings_log , 4 , created_by : user , needstype : 2 ) }
let ( :number_of_lettings_logs ) { LettingsLog . count }
before do
@ -148,7 +149,7 @@ RSpec.describe "User Features" do
context " when searching for specific logs " do
it " displays the logs belonging to the same organisation " do
expect ( page ) . to have_content ( log_to_search . id )
other_logs . each do | log |
( other_general_needs_ logs + other_supported_housing_logs ) . each do | log |
expect ( page ) . to have_content ( log . id )
end
end
@ -168,7 +169,7 @@ RSpec.describe "User Features" do
it " displays log matching the log ID " do
expect ( page ) . to have_link ( log_to_search . id . to_s )
other_logs . each do | log |
( other_general_needs_ logs + other_supported_housing_logs ) . each do | log |
expect ( page ) . not_to have_link ( log . id . to_s )
end
end
@ -187,16 +188,31 @@ RSpec.describe "User Features" do
end
end
it " can filter lettings log s" do
it " has correct page detail s" do
expect ( page ) . to have_content ( " #{ number_of_lettings_logs } total logs " )
organisation . lettings_logs . map ( & :id ) . each do | lettings_log_id |
expect ( page ) . to have_link lettings_log_id . to_s , href : " /lettings-logs/ #{ lettings_log_id } "
end
end
it " can filter lettings logs by year " do
check ( " years-2021-field " )
click_button ( " Apply filters " )
expect ( page ) . to have_current_path ( " /organisations/ #{ org_id } /lettings-logs?years[]=&years[]=2021&status[]=&assigned_to=all&user=&owning_organisation_select=all&owning_organisation= " )
expect ( page ) . to have_current_path ( " /organisations/ #{ org_id } /lettings-logs?years[]=&years[]=2021&status[]=&needstypes[]=& assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&manag ing_organisation= " )
expect ( page ) . not_to have_link first_log . id . to_s , href : " /lettings-logs/ #{ first_log . id } "
end
it " can filter lettings logs by needstype " do
check ( " needstypes-1-field " )
click_button ( " Apply filters " )
expect ( page ) . to have_current_path ( " /organisations/ #{ org_id } /lettings-logs?years[]=&status[]=&needstypes[]=&needstypes[]=1&assigned_to=all&user=&owning_organisation_select=all&owning_organisation=&managing_organisation_select=all&managing_organisation= " )
other_general_needs_logs . each do | general_needs_log |
expect ( page ) . to have_link general_needs_log . id . to_s , href : " /lettings-logs/ #{ general_needs_log . id } "
end
other_supported_housing_logs . each do | supported_housing_log |
expect ( page ) . not_to have_link supported_housing_log . id . to_s , href : " /lettings-logs/ #{ supported_housing_log . id } "
end
end
end
context " when viewing sales logs for specific organisation " do