4.8 test to check if rating is deleted from the db on click from user's page

This commit is contained in:
Aaro Koivukangas
2023-11-11 13:50:21 +02:00
parent 80c4a6bfca
commit 80d848ec47
+41
View File
@@ -18,4 +18,45 @@ describe "User Page" do
expect(page).to have_content "Iso 3 20"
expect(page).to have_content "Iso 3 30"
end
it "before login doesn't show Delete button" do
rating1.save()
rating2.save()
visit user_path(user.id)
expect(page).to_not have_content "Delete"
end
it "after login shows Delete button" do
rating1.save()
rating2.save()
#login
visit new_session_path
fill_in "username", with: "MööttiTesti"
fill_in "password", with: "Unsecure1"
click_button "Log in"
visit user_path(user.id)
expect(page).to have_content "Delete"
end
it "should on rating delete also delete the rating from the database" do
rating1.save()
rating2.save()
expect(Rating.all.count).to be_equal 2
# login
visit new_session_path
fill_in "username", with: "MööttiTesti"
fill_in "password", with: "Unsecure1"
click_button "Log in"
visit user_path(user)
page.first(:link, "Delete").click()
expect(page).to_not have_content "Iso 3 20"
expect(Rating.all.count).to be_equal 1
end
end