diff --git a/app/views/content_viewer/_comment_form.rhtml b/app/views/content_viewer/_comment_form.rhtml index c19a877..423d44e 100644 --- a/app/views/content_viewer/_comment_form.rhtml +++ b/app/views/content_viewer/_comment_form.rhtml @@ -21,8 +21,6 @@ function submit_comment_form(button) { } -<% focus_on = logged_in? ? 'title' : 'name' %> - <% if @comment && @comment.errors.any? && @comment.reply_of_id.blank? %> <%= error_messages_for :comment %> @@ -32,17 +30,7 @@ function submit_comment_form(button) {
- <%= content_tag('a', '', :name => 'comment_form') + _('Post a comment') %> -
-<% end %> + <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') if display_link %> <% unless pass_without_comment_captcha? %><%= _('Post a comment') %>
+ <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') %> <% end %>diff --git a/features/comment.feature b/features/comment.feature index dbeaf27..9420391 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -14,19 +14,23 @@ Feature: comment | article | author | title | body | | article with comment | booking | hi | how are you? | | article with comment | booking | hello | i am fine | + And feature "captcha_for_logged_users" is disabled on environment + And I am logged in as "booking" Scenario: not post a comment without javascript Given I am on /booking/article-to-comment - And I fill in "Name" with "Joey Ramone" - And I fill in "e-mail" with "joey@ramones.com" + And I follow "Post a comment" And I fill in "Title" with "Hey ho, let's go!" And I fill in "Enter your comment" with "Hey ho, let's go!" When I press "Post comment" Then I should not see "Hey ho, let's go" + # This test requires some way to overcome the captcha with unauthenticated + # user. @selenium-fixme Scenario: post a comment while not authenticated Given I am on /booking/article-to-comment + And I follow "Post a comment" And I fill in "Name" with "Joey Ramone" And I fill in "e-mail" with "joey@ramones.com" And I fill in "Title" with "Hey ho, let's go!" @@ -34,58 +38,57 @@ Feature: comment When I press "Post comment" Then I should see "Hey ho, let's go" - @selenium-fixme + @selenium Scenario: post comment while authenticated - Given I am logged in as "booking" - And I am on /booking/article-to-comment + Given I am on /booking/article-to-comment + And I follow "Post a comment" And I fill in "Title" with "Hey ho, let's go!" And I fill in "Enter your comment" with "Hey ho, let's go!" When I press "Post comment" Then I should see "Hey ho, let's go" - @selenium-fixme + @selenium Scenario: redirect to right place after comment a picture Given the following files | owner | file | mime | | booking | rails.png | image/png | - Given I am logged in as "booking" And I am on /booking/rails.png?view=true + And I follow "Post a comment" And I fill in "Title" with "Hey ho, let's go!" And I fill in "Enter your comment" with "Hey ho, let's go!" When I press "Post comment" Then I should be exactly on /booking/rails.png?view=true - @selenium-fixme + @selenium Scenario: show error messages when make a blank comment - Given I am logged in as "booking" - And I am on /booking/article-to-comment + Given I am on /booking/article-to-comment + And I follow "Post a comment" When I press "Post comment" - Then I should see "Title can't be blank" - And I should see "Body can't be blank" + Then I should see "Body can't be blank" @selenium-fixme Scenario: disable post comment button Given I am on /booking/article-to-comment - And I fill in "Name" with "Joey Ramone" - And I fill in "e-mail" with "joey@ramones.com" + And I follow "Post a comment" And I fill in "Title" with "Hey ho, let's go!" And I fill in "Enter your comment" with "Hey ho, let's go!" When I press "Post comment" - Then the "value.Post comment" button should not be enabled - And I should see "Hey ho, let's go" +# Implement these steps... +# Then "Post comment" button should not be enabled +# And I should see "Hey ho, let's go" - @selenium-fixme + @selenium Scenario: render comment form and go to bottom Given I am on /booking/article-with-comment - When I follow "Post a comment" within ".post-comment-button" - Then I should see "Enter your comment" within "div#page-comment-form div.post_comment_box.opened" - And I should be exactly on /booking/article-with-comment - And I should be moved to anchor "comment_form" + When I follow "Post a comment" + Then I should see "Enter your comment" + And I should be on /booking/article-with-comment - @selenium-fixme + @selenium Scenario: keep comments field filled while trying to do a comment Given I am on /booking/article-with-comment - And I fill in "Name" with "Joey Ramone" + And I follow "Post a comment" + And I fill in "Title" with "Joey Ramone" When I press "Post comment" - Then the "Name" field should contain "Joey Ramone" - And I should see "errors prohibited" + Then the "Title" field should contain "Joey Ramone" + And I should see "Body can't be blank" diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 2f1b15e..8d1db1f 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -210,6 +210,16 @@ Then /^(?:|I )should be on (.+)$/ do |page_name| end end +Then /^(?:|I )should be exactly on (.+)$/ do |page_name| + uri = URI.parse(current_url) + path_with_params = "#{uri.path}?#{uri.query}" + if path_with_params.respond_to? :should + path_with_params.should == path_to(page_name) + else + assert_equal path_to(page_name), path_with_params + end +end + Then /^(?:|I )should have the following query string:$/ do |expected_pairs| query = URI.parse(current_url).query actual_params = query ? CGI.parse(query) : {} diff --git a/public/javascripts/comment_form.js b/public/javascripts/comment_form.js new file mode 100644 index 0000000..26cb7bf --- /dev/null +++ b/public/javascripts/comment_form.js @@ -0,0 +1,23 @@ +jQuery('.display-comment-form').click(function(){ + toggleBox('.post_comment_box'); + jQuery('.display-comment-form').hide(); + jQuery('form.comment_form input').first().focus(); + return false; +}); + +jQuery('#cancel-comment').click(function(){ + toggleBox('.post_comment_box'); + jQuery('.display-comment-form').show(); + return false +}) + +function toggleBox(div_selector){ + div = jQuery(div_selector); + if(div.hasClass('opened')) { + div.removeClass('opened'); + div.addClass('closed'); + } else { + div.removeClass('closed'); + div.addClass('opened'); + } +} diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index a65d9d4..3e79a62 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1106,8 +1106,7 @@ a.comment-picture { } #article .article-comments-list, #article .article-comments-list ul, #article .article-comments-list li { padding: 0; - margin: 0; - margin-bottom: 10px; + margin: 25px 0 10px 0; list-style: none; } .article-comment .button-bar { @@ -1273,20 +1272,24 @@ a.comment-picture { background: transparent url(../images/loading-small.gif) no-repeat left center; } + .post_comment_box { text-align: center; padding: 0px 15px 5px 15px; - margin: 10px auto; } -.post-comment-button a, .post_comment_box h4 { + +#comments_list a.display-comment-form { padding: 1px 20px; margin: 0px; background: #eee; -} -.post-comment-button a, .post_comment_box.closed h4 { - display: inline; border: 1px solid #888; - cursor: pointer; + text-decoration: none; + color: black; + font-size: 14px; + font-weight: bold; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; } .post_comment_box.opened { border: 1px solid #888; -- libgit2 0.21.2