Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
add members to room.to_json
Browse files Browse the repository at this point in the history
  • Loading branch information
banjun committed Mar 19, 2015
1 parent 00ccbe2 commit ec7b8d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/room.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def to_json
:name => self.title,
:nickname => self.nickname,
:updated_at => self.updated_at.to_s,
:user => (self.user ? self.user.to_json : nil)
:user => (self.user ? self.user.to_json : nil),
:members => self.members.map(&:to_json)
}
end

Expand Down
6 changes: 6 additions & 0 deletions spec/models/room_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
its([:user]) { should == @user.to_json }
its([:nickname]) { should == "nickname" }
its([:updated_at]) { should == @room.updated_at.to_s }
its([:members]) { should == [] }
end

describe "yaml field" do
Expand Down Expand Up @@ -318,6 +319,11 @@
it { should == [] }
end
end

context "to_json" do
subject { @room.to_json }
its([:members]) { should == [@member.to_json] }
end
end

describe "accessible?" do
Expand Down

0 comments on commit ec7b8d3

Please sign in to comment.