Skip to content

Commit

Permalink
Fix rubocop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
sk8higher committed Nov 12, 2023
1 parent 1b0998c commit 0ef771c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ArticlesController < ApplicationController
before_action :set_article, only: %i[show edit update destroy]

def index
@pagy, @articles = pagy(Article.all.order(created_at: :desc), items: 8)
@pagy, @articles = pagy(Article.order(created_at: :desc), items: 8)
end

def show; end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/buildings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class BuildingsController < ApplicationController
before_action :set_building, only: %i[show edit update destroy]

def index
@pagy, @buildings = pagy(Building.all.order(created_at: :desc), items: 8)
@pagy, @buildings = pagy(Building.order(created_at: :desc), items: 8)
end

def show; end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/monuments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MonumentsController < ApplicationController
before_action :set_monument, only: %i[show edit update destroy]

def index
@pagy, @monuments = pagy(Monument.all.order(created_at: :desc), items: 8)
@pagy, @monuments = pagy(Monument.order(created_at: :desc), items: 8)
end

def show; end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/museums_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class MuseumsController < ApplicationController
before_action :set_museum, only: %i[show edit update destroy]

def index
@pagy, @museums = pagy(Museum.all.order(created_at: :desc), items: 8)
@pagy, @museums = pagy(Museum.order(created_at: :desc), items: 8)
end

def show; end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def index
if params[:tag_id]
@pagy, @people = pagy(Person.where(tag_id: params[:tag_id]).order(created_at: :desc), items: 8)
else
@pagy, @people = pagy(Person.all.order(created_at: :desc), items: 8)
@pagy, @people = pagy(Person.order(created_at: :desc), items: 8)
end
end

Expand Down
24 changes: 12 additions & 12 deletions spec/controllers/articles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@
it 'creates a new article and redirects to the show page' do
expect do
post :create, params: { article: { name_ru: created_article.name_ru,
name_en: created_article.name_en,
name_be: created_article.name_be,
description_ru: created_article.description_ru,
description_en: created_article.description_en,
description_be: created_article.description_be,
images: [file] } }
name_en: created_article.name_en,
name_be: created_article.name_be,
description_ru: created_article.description_ru,
description_en: created_article.description_en,
description_be: created_article.description_be,
images: [file] } }
end.to change(Article, :count).by(1)
expect(response).to redirect_to(assigns(:article))
end

it 'returns unprocessable_entity if article is not saved' do
expect do
post :create, params: { article: { name_ru: nil,
description_ru: nil,
images: file } }
description_ru: nil,
images: file } }
end.not_to change(Article, :count).from(0)

expect(response).to have_http_status(:unprocessable_entity)
Expand All @@ -73,17 +73,17 @@
new_description = Faker::Lorem.characters(number: 40)

patch :update, params: { id: saved_article.id, article: { name_ru: Faker::Lorem.characters(number: 40),
description_ru: new_description,
images: file } }
description_ru: new_description,
images: file } }
expect(response).to redirect_to(assigns(:article))
saved_article.reload
expect(saved_article.description_ru).to eq(new_description)
end

it 'returns unprocessable entity if article is not updated' do
patch :update, params: { id: saved_article.id, article: { name_ru: nil,
description_ru: nil,
images: file } }
description_ru: nil,
images: file } }

expect(response).to have_http_status(:unprocessable_entity)
expect(response).to render_template(:edit)
Expand Down
4 changes: 3 additions & 1 deletion spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

require_relative '../rails_helper'

RSpec.describe ApplicationHelper, type: :helper do
RSpec.describe ApplicationHelper do
describe '#all_locales' do
it 'returns all available locales' do
expect(helper.all_locales).to eq(I18n.available_locales)
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
require_relative './support/factory_bot'
require_relative 'support/factory_bot'
require 'capybara/rspec'

ENV['RAILS_ENV'] ||= 'test'
Expand Down

0 comments on commit 0ef771c

Please sign in to comment.