-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure post owner doesn't change when a post is modified
- Loading branch information
Showing
2 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require "application_system_test_case" | ||
require_relative 'systemtest_helpers.rb' | ||
|
||
class EditingPostsTest < ApplicationSystemTestCase | ||
test_users = { | ||
washington: {email: "[email protected]", pass: "georgepass"}, # admin | ||
jackson: {email: "[email protected]", pass: "jacksonpass"}, # publisher | ||
lincoln: {email: "[email protected]", pass: "lincolnpass"} # subscriber | ||
} | ||
|
||
test "publisher and admin can edit their own posts" do | ||
[test_users[:washington], test_users[:jackson]].each do |test_user| | ||
log_in_with test_user | ||
click_on "New Post Button" | ||
m = "#{rand} I cannot tell a lie!" | ||
fill_in "post_content", with: m | ||
click_on "Save Post" | ||
assert_text m # page previw shows post content | ||
click_on "Home" | ||
assert_text m # recent posts page also shows content of new post" | ||
## Find edit button | ||
## click edit button | ||
## change post content | ||
## validate new post content is saved | ||
click_on "Logout" | ||
end | ||
end | ||
|
||
test "admin editing a post doesn't change ownership of the post" do | ||
log_in_with test_users[:jackson] #publisher | ||
click_on "New Post Button" | ||
m = "#{rand} I cannot tell a lie" | ||
fill_in "post_content", with: m | ||
click_on "Save Post" | ||
assert_text m # page previw shows post content | ||
post_url = current_url | ||
click_on "Logout" | ||
|
||
log_in_with test_users[:washington] #admin | ||
visit post_url | ||
click_on "Edit" | ||
m2 = "#{rand} what a lie" | ||
fill_in "post_content", with: m2 | ||
click_on "Save Post" | ||
assert_text m2 | ||
click_on "Logout" | ||
|
||
log_in_with test_users[:jackson] #publisher | ||
visit post_url | ||
click_on "Edit" | ||
m3 = "#{rand} no lies here" | ||
fill_in "post_content", with: m3 | ||
click_on "Save Post" | ||
assert_text m3 | ||
click_on "Logout" | ||
|
||
end | ||
end |