Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable RSpec/BeNil & RSpec/BeEq for Rubocop #9212

Merged
merged 38 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
644ddbb
Fixing: RSpec/BeEq cop violation in decidim-admin
alecslupu May 2, 2022
9a39666
Fixing: RSpec/BeEq cop violation in decidim-sortitions
alecslupu May 2, 2022
a62c9e5
Fixing: RSpec/BeEq cop violation in decidim-proposals
alecslupu May 2, 2022
8da6393
Fixing: RSpec/BeEq cop violation in decidim-initiatives
alecslupu May 2, 2022
8b87d18
Fixing: RSpec/BeEq cop violation in decidim-elections
alecslupu May 2, 2022
d15da9d
Fixing: RSpec/BeEq cop violation in decidim-forms
alecslupu May 2, 2022
b1e4d4f
Fixing: RSpec/BeEq cop violation in decidim-meetings
alecslupu May 2, 2022
f113f64
Fixing: RSpec/BeEq cop violation in decidim-surveys
alecslupu May 2, 2022
c232e28
Fixing: RSpec/BeEq cop violation in decidim-core
alecslupu May 2, 2022
5ea7bde
Fixing: RSpec/BeEq cop violation in decidim-assemblies
alecslupu May 2, 2022
50320eb
Fixing: RSpec/BeEq cop violation in decidim-budgets
alecslupu May 2, 2022
a25bac9
Fixing: RSpec/BeEq cop violation in decidim-accountability
alecslupu May 2, 2022
e199d01
Fixing: RSpec/BeEq cop violation in decidim-comments
alecslupu May 2, 2022
42c1bcf
Fixing: RSpec/BeEq cop violation in decidim-conferences
alecslupu May 2, 2022
96b225c
Fixing: RSpec/BeEq cop violation in decidim-system
alecslupu May 2, 2022
34dd4da
Fixing: RSpec/BeEq cop violation in decidim-consultations
alecslupu May 2, 2022
c3e62ed
Fixing: RSpec/BeEq cop violation in decidim-debates
alecslupu May 2, 2022
ec14148
Fixing: RSpec/BeEq cop violation in decidim-participatory_processes
alecslupu May 2, 2022
aa722a0
Fixing: RSpec/BeEq cop violation in blogs
alecslupu May 2, 2022
53b166d
Fixing: RSpec/BeEq cop violation in pages
alecslupu May 2, 2022
030dfd5
Fixing: RSpec/BeEq cop violation in decidim-templates
alecslupu May 2, 2022
a6102da
Fixing: RSpec/BeEq cop violation in decidim-verifications
alecslupu May 2, 2022
533385d
Remove RSpec/BeEq from rubocop-disabled
alecslupu May 2, 2022
ee810ae
Remove RSpec/BeNil from rubocop-disabled
alecslupu May 2, 2022
37c8204
Fixing: RSpec/BeNil cop violation in decidim-core
alecslupu May 2, 2022
efcf406
Fixing: RSpec/BeNil cop violation in decidim-admin
alecslupu May 2, 2022
252c613
Fixing: RSpec/BeNil cop violation in decidim-assemblies
alecslupu May 2, 2022
bf4be61
Fixing: RSpec/BeNil cop violation in decidim-meetings
alecslupu May 2, 2022
dd689d5
Fixing: RSpec/BeNil cop violation in decidim-proposals
alecslupu May 2, 2022
2d4a795
Fixing: RSpec/BeNil cop violation in decidim-verifications
alecslupu May 2, 2022
7b6866e
Fixing: RSpec/BeNil cop violation in decidim-budgets
alecslupu May 2, 2022
92f5f91
Fixing: RSpec/BeNil cop violation in decidim-comments
alecslupu May 2, 2022
90240ca
Fixing: RSpec/BeNil cop violation in decidim-conferences
alecslupu May 2, 2022
98904b3
Fixing: RSpec/BeNil cop violation in decidim-consultations
alecslupu May 2, 2022
5f01376
Fixing: RSpec/BeNil cop violation in decidim-forms
alecslupu May 2, 2022
af73b9f
Fixing: RSpec/BeNil cop violation in decidim-initiatives
alecslupu May 2, 2022
b36f5f3
Fixing: RSpec/BeNil cop violation in decidim-sortitions
alecslupu May 2, 2022
5ecd65a
Fixing: RSpec/BeNil cop violation in decidim-participatory_processes
alecslupu May 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions .rubocop-disabled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Rails/EagerEvaluationLogMessage:

Style/FileWrite:
Enabled: false

Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false

Expand All @@ -122,8 +123,10 @@ Rails/DuplicateScope:

RSpec/IdenticalEqualityAssertion:
Enabled: false

Style/StringChars:
Enabled: false

Rails/ExpandedDateRange:
Enabled: false

Expand All @@ -132,13 +135,9 @@ Rails/I18nLocaleTexts:

Naming/MemoizedInstanceVariableName:
Enabled: false
RSpec/VerifiedDoubleReference:
Enabled: false
Rails/TransactionExitStatement:
Enabled: false

RSpec/BeNil:
RSpec/VerifiedDoubleReference:
Enabled: false

RSpec/BeEq:
Rails/TransactionExitStatement:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{ scope: :admin, action: :create, subject: action_subject }
end

it { is_expected.to eq true }
it { is_expected.to be true }
end

describe "update" do
Expand All @@ -30,7 +30,7 @@
end

context "when the resource is present" do
it { is_expected.to eq true }
it { is_expected.to be true }
end

context "when the resource is not present" do
Expand All @@ -46,7 +46,7 @@
end

context "when the resource is present" do
it { is_expected.to eq true }
it { is_expected.to be true }
end

context "when the resource is not present" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ module Decidim::Admin
expect(participatory_process.components).not_to be_empty

component = participatory_process.components.first
expect(component.settings.dummy_global_attribute_1).to eq(true)
expect(component.settings.dummy_global_attribute_2).to eq(false)
expect(component.settings.dummy_global_attribute_1).to be(true)
expect(component.settings.dummy_global_attribute_2).to be(false)
expect(component.weight).to eq 2

step_settings = component.step_settings[step.id.to_s]
expect(step_settings.dummy_step_attribute_1).to eq(true)
expect(step_settings.dummy_step_attribute_2).to eq(false)
expect(step_settings.dummy_step_attribute_1).to be(true)
expect(step_settings.dummy_step_attribute_2).to be(false)
end

it "traces the action", versioning: true do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module Decidim::Admin
expect(newsletter.author).to eq(user)
expect(newsletter.organization).to eq(organization)
expect(newsletter.subject.deep_stringify_keys).to eq(form.subject.deep_stringify_keys)
expect(newsletter.sent?).to eq(false)
expect(newsletter.sent?).to be(false)
expect(newsletter.template).to be_present
expect(newsletter.template.settings.body.stringify_keys).to eq(newsletter_body.stringify_keys.except("machine_translations"))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module Decidim::Admin

expect(published_block2.weight).to eq 1
expect(unpublished_block.weight).to eq 2
expect(published_block1.weight).to eq nil
expect(published_block1.weight).to be_nil
end

it "unpublishes a published block that disappears from the order" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Decidim::Admin
context "when solve conflict succeeds " do
it "mark conflict as solved" do
subject.call
expect(conflict.reload.solved).to eq(true)
expect(conflict.reload.solved).to be(true)
end

it "update email" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Decidim::Admin

it "deletes the moderation" do
command.call
expect(reportable.reload.moderation).to be(nil)
expect(reportable.reload.moderation).to be_nil
end

it "traces the action", versioning: true do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Decidim::Admin

it "deletes the moderation" do
command.call
expect(reportable.reload.user_moderation).to be(nil)
expect(reportable.reload.user_moderation).to be_nil
end

it "traces the action", versioning: true do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ module Decidim::Admin

expect(component["name"]["en"]).to eq("My component")
expect(component.weight).to eq(3)
expect(component.settings.dummy_global_attribute_1).to eq(true)
expect(component.settings.dummy_global_attribute_2).to eq(false)
expect(component.settings.readonly_attribute).to eq(true)
expect(component.settings.dummy_global_attribute_1).to be(true)
expect(component.settings.dummy_global_attribute_2).to be(false)
expect(component.settings.readonly_attribute).to be(true)

step_settings = component.step_settings[step.id.to_s]
expect(step_settings.dummy_step_attribute_1).to eq(true)
expect(step_settings.dummy_step_attribute_2).to eq(false)
expect(step_settings.readonly_step_attribute).to eq(true)
expect(step_settings.dummy_step_attribute_1).to be(true)
expect(step_settings.dummy_step_attribute_2).to be(false)
expect(step_settings.readonly_step_attribute).to be(true)
end

it "fires the hooks" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module Decidim::Admin

expect(newsletter.author).to eq(user)
expect(newsletter.subject.except("machine_translations")).to eq(form.subject.deep_stringify_keys.except("machine_translations"))
expect(newsletter.sent?).to eq(false)
expect(newsletter.sent?).to be(false)
expect(newsletter.template).to be_present
expect(newsletter.template.settings.body.stringify_keys).to eq(newsletter_body.stringify_keys.except("machine_translations"))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ module Decidim::Admin
organization.reload

expect(organization.name).to eq("My super organization")
expect(organization.rich_text_editor_in_public_views).to eq(true)
expect(organization.enable_machine_translations).to eq(true)
expect(organization.rich_text_editor_in_public_views).to be(true)
expect(organization.enable_machine_translations).to be(true)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module Decidim::Admin
page.reload

expect(page.slug).to eq("new-slug")
expect(page.allow_public_access).to eq(true)
expect(page.allow_public_access).to be(true)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ class ImpersonateFakeController < Decidim::Admin::ApplicationController
request.set_header k, [Mime[:js], Mime[:html], Mime[:xml], "text/xml", "*/*"].join(", ")
end
allow(controller).to receive(:request).and_return(request)
expect(controller.send(:check_impersonation_log_expired)).to eq(nil)
expect(controller.send(:check_impersonation_log_expired)).to be_nil
end

it "returns nil on non HTML responses" do
request.set_header "HTTP_ACCEPT", [Mime[:js], Mime[:xml]].join(",")
allow(controller).to receive(:request).and_return(request)
expect(controller.send(:check_impersonation_log_expired)).to eq(nil)
expect(controller.send(:check_impersonation_log_expired)).to be_nil
end

it "redirects when impersonated session is expired" do
expect(controller.send(:check_impersonation_log_expired)).to eq(nil)
expect(controller.send(:check_impersonation_log_expired)).to be_nil
request.set_header "HTTP_ACCEPT", [Mime[:html], "text/html"].join(",")

allow(controller).to receive(:real_user).and_return(user)
Expand Down
14 changes: 7 additions & 7 deletions decidim-admin/spec/controllers/static_pages_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ module Admin
it "assigns the default value for the allow_public_access" do
post :create, params: {}

expect(assigns(:form).allow_public_access).to eq(false)
expect(assigns(:form).allow_public_access).to be(false)
end
end

context "when allow_public_access is given" do
it "does not overwrite it when unchecked" do
put :create, params: { static_page: { allow_public_access: "0" } }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(false)
expect(assigns(:form).allow_public_access).to be(false)
end

it "does not overwrite it when checked" do
post :create, params: { static_page: { allow_public_access: "1" } }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(true)
expect(assigns(:form).allow_public_access).to be(true)
end
end
end
Expand Down Expand Up @@ -75,14 +75,14 @@ module Admin
page.update!(allow_public_access: true)
put :update, params: { id: page.id }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(true)
expect(assigns(:form).allow_public_access).to be(true)
end

it "injects it to the form when set to false" do
page.update!(allow_public_access: false)
put :update, params: { id: page.id }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(false)
expect(assigns(:form).allow_public_access).to be(false)
end
end

Expand All @@ -91,14 +91,14 @@ module Admin
page.update!(allow_public_access: true)
put :update, params: { id: page.id, static_page: { allow_public_access: "0" } }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(false)
expect(assigns(:form).allow_public_access).to be(false)
end

it "does not overwrite it when checked" do
page.update!(allow_public_access: false)
put :update, params: { id: page.id, static_page: { allow_public_access: "1" } }.with_indifferent_access

expect(assigns(:form).allow_public_access).to eq(true)
expect(assigns(:form).allow_public_access).to be(true)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions decidim-admin/spec/forms/static_page_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ module Admin
describe "#control_public_access?" do
context "when organization does not require authentication" do
it "returns false" do
expect(subject.control_public_access?).to eq(false)
expect(subject.control_public_access?).to be(false)
end
end

context "when organization requires authentication" do
let(:organization) { create(:organization, force_users_to_authenticate_before_access_organization: true) }

it "returns true" do
expect(subject.control_public_access?).to eq(true)
expect(subject.control_public_access?).to be(true)
end
end
end
Expand Down