@comic.should_not be_valid
end
end
- context 'widthを検証するとき' do
- it 'nullなら失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :width => nil
- @comic.should_not be_valid
- end
- it '0なら失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :width => 0
- @comic.should_not be_valid
- end
- it '負でも失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :width => -1
- @comic.should_not be_valid
- end
- it '正なら通る' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :width => 1
- @comic.should be_valid
- end
- end
- context 'heightを検証するとき' do
- it 'nullなら失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :height => nil
- @comic.should_not be_valid
- end
- it '0なら失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :height => 0
- @comic.should_not be_valid
- end
- it '負でも失敗する' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :height => -1
- @comic.should_not be_valid
- end
- it '正なら通る' do
- @comic = FactoryGirl.build :comic, :author_id => @author.id, :height => 1
- @comic.should be_valid
- end
- end
context 'visibleを検証するとき' do
it 'nullなら失敗する' do
@comic = FactoryGirl.build :comic, :author_id => @author.id, :visible => nil
c.should eq @comic
end
end
+ describe '編集取得に於いて' do
+ before do
+ @comic = FactoryGirl.create :comic, :author_id => @author.id
+ end
+ it '指定のコミックを返す' do
+ Comic.any_instance.stub(:own?).and_return(true)
+ c = Comic.edit @comic.id, @author.id
+ c.should eq @comic
+ end
+ context '他人のコミックを開こうとしたとき' do
+ it '403Forbidden例外を返す' do
+ Comic.any_instance.stub(:own?).and_return(false)
+ lambda{
+ Comic.edit @comic.id, @author
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ context '存在しないコミックを開こうとしたとき' do
+ it '404RecordNotFound例外を返す' do
+ lambda{
+ Comic.edit 110, @author
+ }.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
+ end
describe '関連テーブルプションに於いて' do
context 'オプションがないとき' do
it '2つの項目を含んでいる' do