Skip to content

Commit

Permalink
breaking test when two column based attributes are aliased
Browse files Browse the repository at this point in the history
  • Loading branch information
skunkworker committed Sep 7, 2023
1 parent 08a76fb commit 3605c4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/import_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -991,4 +991,16 @@
end
end
end

describe "aliased attributes" do
it "two column based attributes can be imported" do
topic = FactoryBot.create :topic
new_topic = Topic.new(topic.attributes.except("id"))
new_topic.author_name = "John Doe"

Topic.import([new_topic])
assert_equal 2, Topic.count
end
end

end
1 change: 1 addition & 0 deletions test/models/topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Topic < ActiveRecord::Base
self.ignored_columns = [:priority]
end
alias_attribute :name, :title
alias_attribute :author_full_name, :author_name

validates_presence_of :author_name
validates :title, numericality: { only_integer: true }, on: :context_test
Expand Down
1 change: 1 addition & 0 deletions test/schema/generic_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
t.datetime :created_on
t.datetime :updated_at
t.datetime :updated_on
t.string :author_full_name
end

create_table :projects, force: :cascade do |t|
Expand Down

0 comments on commit 3605c4f

Please sign in to comment.