Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 20, 2024
1 parent 755c272 commit e7b0a93
Show file tree
Hide file tree
Showing 28 changed files with 588 additions and 452 deletions.
10 changes: 6 additions & 4 deletions spec/datagrid/active_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ class ActiveReport
end

describe ".model_name" do
it "should be generate from class name " do
it "is generate from class name" do
expect(ActiveReport.model_name).to eq("ActiveReport")
end
it "should have ActiveModel naming conventions" do

it "has ActiveModel naming conventions" do
expect(ActiveReport.model_name.i18n_key).to eq(:active_report)
end
end

describe ".param_name" do
it "should make right param key from simple class name" do
it "makes right param key from simple class name" do
expect(ActiveReport.param_name).to eq("active_report")
end
it "should make right param key from class of module" do

it "makes right param key from class of module" do
expect(Grid::ActiveReport.param_name).to eq("grid_active_report")
end
end
Expand Down
21 changes: 11 additions & 10 deletions spec/datagrid/column_names_attribute_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
require "spec_helper"

describe Datagrid::ColumnNamesAttribute do
subject { report }

let(:column_names_filter_options) do
{}
end
let!(:entry) do
Entry.create!(name: "hello", category: "greeting")
end

let(:report) do
options = column_names_filter_options
Expand All @@ -17,13 +22,8 @@
column(:category)
end
end
subject { report }

let!(:entry) do
Entry.create!(name: "hello", category: "greeting")
end

it "should work" do
it "works" do
subject.column_names = [:id]
expect(subject.mandatory_columns.map(&:name)).to eq([:name])
expect(subject.optional_columns.map(&:name)).to eq(%i[id category])
Expand All @@ -33,19 +33,19 @@
expect(columns_filter.select(subject)).to eq([["Id", :id], ["Category", :category]])
end

it "should show only mandatory columns by default" do
it "shows only mandatory columns by default" do
expect(subject.row_for(entry)).to eq(["hello"])
subject.column_names = %w[name category]
expect(subject.row_for(entry)).to eq(%w[hello greeting])
end

it "should show mandatory columns even if they are unselected" do
it "shows mandatory columns even if they are unselected" do
subject.column_names = ["category"]
expect(subject.row_for(entry)).to eq(%w[hello greeting])
expect(subject.data).to eq([%w[Name Category], %w[hello greeting]])
end

it "should find any column by name" do
it "finds any column by name" do
expect(subject.column_by_name(:id)).not_to be_nil
expect(subject.column_by_name(:name)).not_to be_nil
expect(subject.column_by_name(:category)).not_to be_nil
Expand All @@ -58,7 +58,8 @@

describe "#data" do
subject { super().data }
it { should == [%w[Id Name], [entry.id, "hello"]] }

it { is_expected.to eq([%w[Id Name], [entry.id, "hello"]]) }
end
end

Expand Down
Loading

0 comments on commit e7b0a93

Please sign in to comment.