Skip to content

Commit

Permalink
fix: test fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Waishnav committed Jul 21, 2024
1 parent f6977ee commit 379198e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/controllers/simple_discussion/forum_posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def create
SimpleDiscussion::ForumPostNotificationJob.perform_later(@forum_post)
redirect_to simple_discussion.forum_thread_path(@forum_thread, anchor: "forum_post_#{@forum_post.id}")
else
render template: "simple_discussion/forum_threads/show"
render template: "simple_discussion/forum_threads/show", status: :unprocessable_entity
end
end

Expand All @@ -24,7 +24,7 @@ def update
if @forum_post.update(forum_post_params)
redirect_to simple_discussion.forum_thread_path(@forum_thread)
else
render action: :edit
render action: :edit, status: :unprocessable_entity
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/simple_discussion/forum_threads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create
SimpleDiscussion::ForumThreadNotificationJob.perform_later(@forum_thread)
redirect_to simple_discussion.forum_thread_path(@forum_thread)
else
render action: :new
render action: :new, status: :unprocessable_entity
end
end

Expand All @@ -56,7 +56,7 @@ def update
if @forum_thread.update(forum_thread_params)
redirect_to simple_discussion.forum_thread_path(@forum_thread), notice: I18n.t("your_changes_were_saved")
else
render action: :edit
render action: :edit, status: :unprocessable_entity
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/forum_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class ForumPost < ApplicationRecord
belongs_to :forum_thread, counter_cache: true, touch: true
belongs_to :user

before_validation :clean_body, if: -> { SimpleDiscussion.profanity_filter }
validates :user_id, :body, presence: true
validate :clean_body, if: -> { SimpleDiscussion.profanity_filter }

scope :sorted, -> { order(:created_at) }

Expand Down
2 changes: 1 addition & 1 deletion app/models/forum_thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ForumThread < ApplicationRecord
validates :user_id, :title, presence: true
validates_associated :forum_posts

before_validation :clean_title, if: -> { SimpleDiscussion.profanity_filter }
validate :clean_title, if: -> { SimpleDiscussion.profanity_filter }

scope :pinned_first, -> { order(pinned: :desc) }
scope :solved, -> { where(solved: true) }
Expand Down

0 comments on commit 379198e

Please sign in to comment.