before do
@f = Rails.root + 'spec/json/color.json'
@fs = Rails.root + 'spec/json/colors.json'
- FactoryGirl.create :admin
+ @admin = FactoryGirl.create :admin
@user = FactoryGirl.create( :user_yas)
- @author = @user.author
+ @author = FactoryGirl.create :author, :user_id => @user.id
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
@other_user = FactoryGirl.create( :user_yas)
- @other_author = @other_user.author
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
@other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
@sp = FactoryGirl.create :system_picture
@lg = FactoryGirl.create :license_group
before do
@c = FactoryGirl.build :color
end
- it '許可する' do\r
+ it '許可する' do
@c.visible?(@author).should == true
- end\r
+ end
end
describe '一覧取得に於いて' do
Color.page_size('1000').should eq Color.max_page_size
end
end
- context 'つつがなく終わるとき' do\r
- it '一覧取得オプションを利用している' do\r
- Color.stub(:list_opt).with(any_args).and_return({})\r
- Color.should_receive(:list_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ Color.stub(:list_opt).with(any_args).and_return({})
+ Color.should_receive(:list_opt).with(any_args).exactly(1)
r = Color.list
- end\r
- end\r
+ end
+ end
it 'リストを返す' do
r = Color.list
r.should eq [@c]
@color3 = FactoryGirl.create :color, :name => 'new color b', :t => 2
@color4 = FactoryGirl.create :color, :name => 'new color c', :t => 3
@color5 = FactoryGirl.create :color, :name => 'new color d', :t => 4
- Color.stub(:default_page_size).and_return(0)
+ Color.stub(:default_page_size).and_return(2)
end
it '通常は全件(5件)を返す' do
- r = Color.list
+ r = Color.list 5, 0
r.should have(5).items
end
end
before do
@c = FactoryGirl.create :color
end
- context 'つつがなく終わるとき' do\r
- it '単体取得オプションを利用している' do\r
- Color.stub(:show_opt).with(any_args).and_return({})\r
- Color.should_receive(:show_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '単体取得オプションを利用している' do
+ Color.stub(:show_opt).with(any_args).and_return({})
+ Color.should_receive(:show_opt).with(any_args).exactly(1)
r = Color.show @c.id, @author
- end\r
- it '閲覧許可を問い合わせている' do\r
- Color.any_instance.stub(:visible?).with(any_args).and_return(true)\r
- Color.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
+ end
+ it '閲覧許可を問い合わせている' do
+ Color.any_instance.stub(:visible?).with(any_args).and_return(true)
+ Color.any_instance.should_receive(:visible?).with(any_args).exactly(1)
r = Color.show @c.id, @author
- end\r
- end\r
+ end
+ end
it '指定の色を返す' do
r = Color.show @author.id, @author
r.should eq @c
end
- context '閲覧許可が出なかったとき' do\r
- it '403Forbidden例外を返す' do\r
- Color.any_instance.stub(:visible?).and_return(false)\r
- lambda{\r
- Color.show @c.id, @author\r
- }.should raise_error(ActiveRecord::Forbidden)\r
- end\r
- end\r
- context '存在しない色を開こうとしたとき' do\r
- it '404RecordNotFound例外を返す' do\r
- lambda{\r
- Color.show 110, @author\r
- }.should raise_error(ActiveRecord::RecordNotFound)\r
- end\r
- end\r
+ context '閲覧許可が出なかったとき' do
+ it '403Forbidden例外を返す' do
+ Color.any_instance.stub(:visible?).and_return(false)
+ lambda{
+ Color.show @c.id, @author
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ context '存在しない色を開こうとしたとき' do
+ it '404RecordNotFound例外を返す' do
+ lambda{
+ Color.show 110, @author
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
end
describe '単体取得オプションに於いて' do