From e7e065f880311fe55651125dfbe46b16f9f2d047 Mon Sep 17 00:00:00 2001 From: Slava <53832230+slavalamp@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:01:05 +0100 Subject: [PATCH] AO3-5502 satisfy more Rubocop --- app/controllers/chapters_controller.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/chapters_controller.rb b/app/controllers/chapters_controller.rb index 7b31a09546..bdab981c76 100644 --- a/app/controllers/chapters_controller.rb +++ b/app/controllers/chapters_controller.rb @@ -29,9 +29,7 @@ def manage def show @tag_groups = @work.tag_groups - if params[:selected_id] - redirect_to url_for(controller: :chapters, action: :show, work_id: @work.id, id: params[:selected_id]) and return - end + redirect_to url_for(controller: :chapters, action: :show, work_id: @work.id, id: params[:selected_id]) and return if params[:selected_id] @chapters = @work.chapters_in_order( include_content: false, @@ -91,6 +89,7 @@ def new # GET /work/:work_id/chapters/1/edit def edit return unless params["remove"] == "me" + @chapter.creatorships.for_user(current_user).destroy_all if @work.chapters.any? { |c| current_user.is_author_of?(c) } flash[:notice] = ts("You have been removed as a creator from the chapter.") @@ -266,16 +265,14 @@ def load_work def load_chapter @chapter = @work.chapters.find_by(id: params[:id]) - unless @chapter - flash[:error] = ts("Sorry, we couldn't find the chapter you were looking for.") - redirect_to work_path(@work) - end + return if @chapter + + flash[:error] = ts("Sorry, we couldn't find the chapter you were looking for.") + redirect_to work_path(@work) end def post_chapter - unless @work.posted - @work.update_attribute(:posted, true) - end + @work.update_attribute(:posted, true) unless @work.posted flash[:notice] = ts("Chapter has been posted!") end