diff --git a/app/views/comments/_form.html.slim b/app/views/comments/_form.html.slim index 7fe7f82..7774b7a 100644 --- a/app/views/comments/_form.html.slim +++ b/app/views/comments/_form.html.slim @@ -10,3 +10,12 @@ = f.submit 'Save changes', class: 'btn btn-success' ' a.btn.btn-default href=cancel_comment_path(comment) data-remote="true" Cancel + +javascript: + $('#edit_comment_#{comment.id}').validate({ + rules: { + 'comment[body]': { + required: true + } + } + }); diff --git a/app/views/topics/_form.html.slim b/app/views/topics/_form.html.slim index 641fc61..cbf34ec 100644 --- a/app/views/topics/_form.html.slim +++ b/app/views/topics/_form.html.slim @@ -1,4 +1,4 @@ -= form_for @topic, remote: true, html: { class: 'form-topic' } do |f| += form_for @topic, remote: true, html: { class: 'topic-form' } do |f| .row .col-md-9 .form-group @@ -14,3 +14,17 @@ = f.submit 'Save changes', class: 'btn btn-success', tabIndex: 4 ' a.btn.btn-default href=topic_path(@topic) tabIndex="5" Cancel + +- form_id = @topic.new_record? ? 'new_topic' : "edit_topic_#{@topic.id}" + +javascript: + $('##{form_id}').validate({ + rules: { + 'topic[title]': { + required: true + }, + 'topic[body]': { + required: true + } + } + }); diff --git a/app/views/topics/show.html.slim b/app/views/topics/show.html.slim index a3c5204..15c5fdf 100644 --- a/app/views/topics/show.html.slim +++ b/app/views/topics/show.html.slim @@ -88,3 +88,11 @@ javascript: campo.Likes.updateLikes('comment', #{current_user.likes.where(likeable_type: 'Comment', likeable_id: @comments.pluck(:id)).pluck(:likeable_id)}); + + $('#new_comment').validate({ + rules: { + 'comment[body]': { + required: true + } + } + }); diff --git a/test/controllers/admin/users_controller_test.rb b/test/controllers/admin/users_controller_test.rb index e5f3184..272220e 100644 --- a/test/controllers/admin/users_controller_test.rb +++ b/test/controllers/admin/users_controller_test.rb @@ -27,7 +27,6 @@ class Admin::UsersControllerTest < ActionController::TestCase assert_difference "User.count", -1 do delete :destroy, id: user end - assert_redirected_to admin_users_path end test "should lock user" do