Updated mod serializer

master
Zequez 2015-08-07 10:43:31 -03:00
parent 7db27d031d
commit c3e26ea65c
2 changed files with 7 additions and 7 deletions

View File

@ -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

View File

@ -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
})