Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

at_timestamp: rubocop refactoring

Sebastian Fiedlschuster1c39be6342c3
diff --git a/spec/models/journable/historic_active_record_relation_spec.rb b/spec/models/journable/historic_active_record_relation_spec.rb
index ae8d73db0cc..33a5403e799 100644
--- a/spec/models/journable/historic_active_record_relation_spec.rb
+++ b/spec/models/journable/historic_active_record_relation_spec.rb
@@ -384,6 +384,7 @@ describe Journable::HistoricActiveRecordRelation do
describe "#first" do
describe "for columns that don't exist in the journal-data table" do
let(:column_name) { :lock_version }
+
subject { historic_relation.first.send(column_name) }
specify "the column name does exist in the journable table" do
@@ -395,7 +396,7 @@ describe Journable::HistoricActiveRecordRelation do
end
it "has the attribute with null value" do
- expect(historic_relation.first.attributes_before_type_cast[column_name]).to be nil
+ expect(historic_relation.first.attributes_before_type_cast[column_name]).to be_nil
end
it "has the typecasted value matching the journable class's data type" do
diff --git a/spec/models/journable/timestamps_spec.rb b/spec/models/journable/timestamps_spec.rb
index d3002ef3521..f410d976f29 100644
--- a/spec/models/journable/timestamps_spec.rb
+++ b/spec/models/journable/timestamps_spec.rb
@@ -26,10 +26,6 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-# rubocop:disable RSpec/ClassCheck
-# Prefer `kind_of?` over `is_a?` because it reads well before vowel and consonant sounds.
-# E.g.: `relation.kind_of? ActiveRecord::Relation`
-
require 'spec_helper'
describe Journable::Timestamps do
@@ -87,16 +83,16 @@ describe Journable::Timestamps do
subject { WorkPackage.at_timestamp(timestamp) }
it "returns a historic active-record relation" do
- expect(subject).to be_kind_of Journable::HistoricActiveRecordRelation
- expect(subject).to be_kind_of ActiveRecord::Relation
+ expect(subject).to be_a Journable::HistoricActiveRecordRelation
+ expect(subject).to be_an ActiveRecord::Relation
end
describe "chaining a where clause" do
subject { WorkPackage.at_timestamp(timestamp).where(assigned_to_id: 1) }
it "still returns a historic active-record relation" do
- expect(subject).to be_kind_of Journable::HistoricActiveRecordRelation
- expect(subject).to be_kind_of ActiveRecord::Relation
+ expect(subject).to be_a Journable::HistoricActiveRecordRelation
+ expect(subject).to be_an ActiveRecord::Relation
end
end
@@ -356,7 +352,7 @@ describe Journable::Timestamps do
it "returns an error because maximum returns a float rather than a relation" do
expect { subject }.to raise_error NoMethodError
- expect(WorkPackage.maximum(:estimated_hours)).to be_kind_of Float
+ expect(WorkPackage.maximum(:estimated_hours)).to be_a Float
end
end
end
@@ -560,7 +556,7 @@ describe Journable::Timestamps do
end
it "has the attribute with null value" do
- expect(subject.attributes_before_type_cast[column_name]).to be nil
+ expect(subject.attributes_before_type_cast[column_name]).to be_nil
end
it "has the typecasted value matching the journable class's data type" do
@@ -646,5 +642,3 @@ describe Journable::Timestamps do
end
end
end
-
-# rubocop:enable RSpec/ClassCheck