-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unable to get the right testing for the confirm dialog box-- may need to add Selenium to test it? Should make it so only author can delete her own posts...
- Loading branch information
Showing
6 changed files
with
42 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
<h1><%= link_to post.title, post %></h1> | ||
<h4>By: <%= post.author.email %></h4> | ||
<% if user_signed_in? %> | ||
<%= link_to "Delete this post", post, method: :delete, data: { confirm: "Are you sure?" }, title: post.title %> | ||
<% end %> | ||
<p><%= post.body %></p> |
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,25 @@ | ||
Feature: Authors can delete posts | ||
|
||
Scenario: I can delete a post I wrote | ||
Given I am signed in as "[email protected]" | ||
Given the following posts: | ||
| title | body | | ||
| Foo | Foo Bar | | ||
When I go to the homepage | ||
And I click "Delete this post" | ||
Then I should see "Your post has been deleted" | ||
And I should be on the homepage | ||
And I should not see the title "Foo" | ||
And I should not see "Foo Bar" | ||
|
||
Scenario: I cannot delete posts if I am not signed in | ||
Given I am not signed in | ||
Given the following posts: | ||
| title | body | | ||
| Foo | Foo Bar | | ||
When I go to the homepage | ||
Then I should not see "Delete this post" | ||
And I should be on the homepage | ||
And I should see the title "Foo" | ||
And I should see "Foo Bar" | ||
|
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 |
---|---|---|
|
@@ -16,6 +16,10 @@ | |
sign_in_as @user | ||
end | ||
|
||
Given /^I am not signed in$/ do | ||
@user = nil | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
maxbeizer
Author
|
||
end | ||
|
||
def sign_in_as user | ||
steps %Q{ | ||
Given I am on the homepage | ||
|
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 doesn't ensure that you aren't signed in. It just sets the @user instance variable to nil. To ensure that the browser is actually signed out, you have to actually go to the logout route.
e.g.: