Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll comments #1961

Merged
Prev Previous commit
Next Next commit
20171004 - Refactored specs for polls comments
 On branch mlucena-poll-comments
 Changes to be committed:
	modified:   app/views/comments/show.html.erb
	modified:   spec/features/polls/polls_spec.rb
  • Loading branch information
zamuro committed Oct 6, 2017
commit c3d7d47c3f24de2ffa90edbb66f3b42d6704946d
2 changes: 1 addition & 1 deletion app/views/comments/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="row">
<div class="small-12 column margin-top">
<%= back_link_to commentable_path(@comment),
t("comments.show.return_to_commentable") + @comment.commentable.title %>
t("comments.show.return_to_commentable") + @comment.commentable.title unless @comment != "Poll" %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State this in the Warning section too, please

</div>
</div>

Expand Down
52 changes: 48 additions & 4 deletions spec/features/polls/polls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,23 +271,67 @@
end
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either add to the Warning section of this PR that only the basic scenarios have been tested
or test all the scenarios that a comment can have https://github.com/consul/consul/blob/master/spec/features/comments/proposals_spec.rb

scenario 'user can reply to comment' do
scenario 'user b can access to comments from user a' do
oliver = create(:user, username: 'Oliver Atom')
benji = create(:user, username: 'Benji Prince')
create(:comment, commentable: poll, user: oliver)

login_as(oliver)
login_as(benji)
visit poll_path(poll)

expect(page).to have_content oliver.username
end

scenario 'user can upvote a comment' do
scenario 'user b can reply to comments from user a', :js do
koji = create(:user, username: 'Koji Kabuto')
sayaka = create(:user, username: 'Sayaka')
comment = create(:comment, commentable: poll, user: koji)

login_as(sayaka)
visit poll_path(poll)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
fill_in "comment-body-comment_#{comment.id}", with: 'MAZINGER!!.'
click_button 'Publish reply'
end

within "#comment_#{comment.id}" do
expect(page).to have_content 'MAZINGER!!.'
end

expect(page).to_not have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
end

scenario 'user can upvote a comment', :js do
goku = create(:user, username: 'Goku')
vegeta = create(:user, username: 'Vegeta')
comment = create(:comment, commentable: poll, user: goku)

login_as(vegeta)
visit poll_path(poll)

within("#comment_#{comment.id}_votes") do
find('.in_favor a').click

expect(page).to have_content "1 vote"
end
end

scenario 'user can downvote a comment' do
scenario 'user can downvote a comment', :js do
doraemon = create(:user, username: 'Doraemon')
nobita = create(:user, username: 'Nobi Nobita')
comment = create(:comment, commentable: poll, user: doraemon)

login_as(nobita)
visit poll_path(poll)

within("#comment_#{comment.id}_votes") do
find('.against a').click

expect(page).to have_content "1 vote"
end
end
end
end