mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
4.8 test to check if rating is deleted from the db on click from user's page
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user