diff --git a/app/serializers/mod_serializer.rb b/app/serializers/mod_serializer.rb index 6fde140..c383c9d 100644 --- a/app/serializers/mod_serializer.rb +++ b/app/serializers/mod_serializer.rb @@ -1,5 +1,5 @@ class ModSerializer < ActiveModel::Serializer - attributes :id, :url, :categories, :authors, :contact + attributes :id, :url, :categories, :author, :contact attribute :name, key: :title attribute :info_json_name, key: :name @@ -15,8 +15,8 @@ class ModSerializer < ActiveModel::Serializer object.categories.map(&:slug) end - def authors - object.authors.map(&:name) + def author + object.author && object.author.name end def url diff --git a/spec/serializers/mod_serializer_spec.rb b/spec/serializers/mod_serializer_spec.rb index 6488e08..0e1bfd9 100644 --- a/spec/serializers/mod_serializer_spec.rb +++ b/spec/serializers/mod_serializer_spec.rb @@ -1,10 +1,10 @@ describe ModSerializer do before :each do - authors = [create(:author, name: 'John Snow Zombie'), create(:author, name: 'THAT Guy')] + author = create(:author, name: 'John Snow Zombie') @mod = create :mod, name: 'Potato Galaxy', info_json_name: 'potato-galaxy-mod', - authors: authors, + author: author, contact: 'Send a homing pigeon to Castle Black', official_url: 'http://castleblack.com', summary: 'This mod adds the ability to farm potatoes on Factorio.', @@ -24,7 +24,7 @@ describe ModSerializer do description: 'This mod adds the ability to farm potatoes on Factorio.', homepage: 'http://castleblack.com', contact: 'Send a homing pigeon to Castle Black', - authors: ['John Snow Zombie', 'THAT Guy'], + author: 'John Snow Zombie', categories: ['potato', 'apple'], releases: @mod.versions.map{|mv| ModVersionSerializer.new mv}.as_json }) @@ -40,7 +40,7 @@ describe ModSerializer do description: 'This mod adds the ability to farm potatoes on Factorio.', homepage: 'http://castleblack.com', contact: 'Send a homing pigeon to Castle Black', - authors: ['John Snow Zombie', 'THAT Guy'], + author: 'John Snow Zombie', categories: ['potato', 'apple'], releases: specific_versions.map{|mv| ModVersionSerializer.new mv}.as_json })