Skip to content

Commit

Permalink
Fix new RuboCop offences
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Dec 24, 2021
1 parent 92e5962 commit b611d6e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
21 changes: 12 additions & 9 deletions spec/unit/filters/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
end

it "should return the defaults if no filters are set" do
expect(resource.filters.keys).to match_array([
:author, :body, :category, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :taggings, :tags, :title, :updated_at, :foo_id
])
expect(resource.filters.keys).to match_array(
[
:author, :body, :category, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :taggings, :tags, :title, :updated_at, :foo_id
])
end

it "should not have defaults when filters are disabled on the resource" do
Expand All @@ -34,9 +35,10 @@

it "should return the defaults without associations if default association filters are disabled on the namespace" do
resource.namespace.include_default_association_filters = false
expect(resource.filters.keys).to match_array([
:body, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :title, :updated_at, :foo_id
])
expect(resource.filters.keys).to match_array(
[
:body, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :title, :updated_at, :foo_id
])
end

describe "removing a filter" do
Expand Down Expand Up @@ -103,9 +105,10 @@
resource.preserve_default_filters!
resource.add_filter :count, as: :string

expect(resource.filters.keys).to match_array([
:author, :body, :category, :count, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :taggings, :tags, :title, :updated_at, :foo_id
])
expect(resource.filters.keys).to match_array(
[
:author, :body, :category, :count, :created_at, :custom_created_at_searcher, :custom_title_searcher, :custom_searcher_numeric, :position, :published_date, :starred, :taggings, :tags, :title, :updated_at, :foo_id
])
end

it "should raise an exception when filters are disabled" do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/view_helpers/fields_for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
include ActiveAdmin::ViewHelpers::FormHelper

it "should skip :action, :controller and :commit" do
expect(fields_for_params(
scope: "All", action: "index", controller: "PostController", commit: "Filter", utf8: "Yes!")).
expect(
fields_for_params(scope: "All", action: "index", controller: "PostController", commit: "Filter", utf8: "Yes!")).
to eq [ { scope: "All" } ]
end

Expand Down
10 changes: 4 additions & 6 deletions spec/unit/views/components/attributes_table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,11 @@
row :created_at
end
end
expect(table.find_by_tag("tr").first.to_s.
split("\n").first.lstrip).
to eq '<tr class="row row-title">'
expect(table.find_by_tag("tr").first.to_s.split("\n").first.lstrip).
to eq '<tr class="row row-title">'

expect(table.find_by_tag("tr").last.to_s.
split("\n").first.lstrip).
to eq '<tr class="row row-created_at">'
expect(table.find_by_tag("tr").last.to_s.split("\n").first.lstrip).
to eq '<tr class="row row-created_at">'
end

it "should allow html options for the row itself" do
Expand Down
9 changes: 5 additions & 4 deletions spec/unit/views/components/table_for_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,11 @@
end

let(:collection) do
Post.create([
{ title: "First Post", starred: true },
{ title: "Second Post" },
])
Post.create(
[
{ title: "First Post", starred: true },
{ title: "Second Post" },
])
Post.where(starred: true)
end

Expand Down

0 comments on commit b611d6e

Please sign in to comment.