mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Replace has_one with attribute in template
This commit is contained in:
parent
a8243761fe
commit
79653ac733
@ -3,6 +3,6 @@ class <%= class_name %>Serializer < <%= parent_class_name %>
|
|||||||
attributes <%= attributes_names.map(&:inspect).join(", ") %>
|
attributes <%= attributes_names.map(&:inspect).join(", ") %>
|
||||||
end
|
end
|
||||||
<% association_names.each do |attribute| -%>
|
<% association_names.each do |attribute| -%>
|
||||||
has_one :<%= attribute %>
|
attribute :<%= attribute %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|||||||
@ -46,7 +46,7 @@ class SerializerGeneratorTest < Rails::Generators::TestCase
|
|||||||
run_generator
|
run_generator
|
||||||
assert_file "app/serializers/account_serializer.rb" do |serializer|
|
assert_file "app/serializers/account_serializer.rb" do |serializer|
|
||||||
assert_match(/^ attributes :id, :name, :description$/, serializer)
|
assert_match(/^ attributes :id, :name, :description$/, serializer)
|
||||||
assert_match(/^ has_one :business$/, serializer)
|
assert_match(/^ attribute :business$/, serializer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user