self.to_json({:include => {:author => {}}, :methods => :elements})
end
+ def self.list_as_json_text ary
+ '[' + ary.map {|i| i.panel_elements_as_json }.join(',') + ']'
+ end
+
def self.visible_count
Panel.count
end
#t:1\r
end\r
end\r
+ describe 'コマリストのjson出力に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ Panel.any_instance.stub(:panel_elements_as_json).with(any_args).and_return('{"p": 5}')\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'コマのjson出力を依頼している' do\r
+ Panel.any_instance.should_receive(:panel_elements_as_json).with(any_args).exactly(1)\r
+ r = Panel.list_as_json_text [@panel]\r
+ end\r
+ end\r
+ it 'json textを返している' do\r
+ r = Panel.list_as_json_text [@panel]\r
+ j = JSON.parse r\r
+ j.is_a?(Array).should be_true\r
+ end\r
+ it 'コマを含んでいる' do\r
+ r = Panel.list_as_json_text [@panel]\r
+ j = JSON.parse r\r
+ j.first.has_key?('p').should be_true\r
+ end\r
+ end\r
describe '検証値収集に於いて' do\r
context 'つつがなく終わるとき' do\r
it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do\r