parent
2df4a1cc5c
commit
787c1cfce9
2 changed files with 12 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
module Export
|
module Export
|
||||||
class CommentSerializer < ActiveModel::Serializer
|
class CommentSerializer < ActiveModel::Serializer
|
||||||
attributes :text,
|
attributes :guid,
|
||||||
|
:text,
|
||||||
:post_guid
|
:post_guid
|
||||||
|
|
||||||
def post_guid
|
def post_guid
|
||||||
|
|
|
||||||
10
spec/serializers/comment_serializer_spec.rb
Normal file
10
spec/serializers/comment_serializer_spec.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
describe Export::CommentSerializer do
|
||||||
|
let(:comment) { create(:comment) }
|
||||||
|
subject(:json_output) { Export::CommentSerializer.new(comment).to_json }
|
||||||
|
|
||||||
|
it { is_expected.to include("\"guid\":\"#{comment.guid}\"") }
|
||||||
|
it { is_expected.to include("\"post_guid\":\"#{comment.post.guid}\"") }
|
||||||
|
it { is_expected.to include("\"text\":\"#{comment.text}\"") }
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue