1 # -*- encoding: utf-8 -*-
\r
7 @license = Factory :license
8 @user = Factory( :user_yas)
10 @artist = Factory :artist_yas, :author_id => @author.id
\r
11 @other_user = Factory( :user_yas)
12 @other_author = @other_user.author
13 @other_artist = Factory :artist_yas, :author_id => @other_author.id
19 @st = Factory :speech_template
\r
20 @comic = Factory :comic, :author_id => @author.id
21 @panel = Factory :panel, :author_id => @author.id, :comic_id => @comic.id
22 @balloon = Factory :balloon, :panel_id => @panel.id, :t => 0
23 @speech = Factory.build :speech, :balloon => @balloon.id, :t => 0
26 it 'オーソドックスなデータなら通る' do
27 @speech.should be_valid
30 context 'balloon_idを検証するとき' do
34 @speech.comic_id = @comic.id
35 @speech.should be_valid
38 @speech.comic_id = nil
39 @speech.should_not be_valid
42 @speech.comic_id = 'a'
43 @speech.should_not be_valid
45 it '存在するコミックでなければ失敗する' do
47 @speech.should_not be_valid
49 it 'コミックidとtが重複していると失敗する' do
51 @speech2 = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
52 @speech2.should_not be_valid
55 context 'resource_picture_idを検証するとき' do
57 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
60 @speech.resource_picture_id = 1
61 @speech.should be_valid
64 @speech.resource_picture_id = nil
65 @speech.should be_valid
68 @speech.resource_picture_id = 'a'
69 @speech.should_not be_valid
71 it '存在する素材でなければ失敗する' do
72 @speech.resource_picture_id = 0
73 @speech.should_not be_valid
76 context 'widthを検証するとき' do
78 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
82 @speech.should be_valid
86 @speech.should_not be_valid
90 @speech.should_not be_valid
94 @speech.should_not be_valid
98 @speech.should_not be_valid
101 context 'heightを検証するとき' do
103 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
107 @speech.should be_valid
111 @speech.should_not be_valid
115 @speech.should_not be_valid
119 @speech.should_not be_valid
123 @speech.should_not be_valid
126 context 'borderを検証するとき' do
128 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
132 @speech.should be_valid
136 @speech.should_not be_valid
140 @speech.should_not be_valid
143 @speech.border = '-1'
144 @speech.should_not be_valid
148 @speech.should be_valid
151 context 'xを検証するとき' do
153 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
157 @speech.should be_valid
161 @speech.should_not be_valid
165 @speech.should be_valid
169 @speech.should be_valid
172 context 'yを検証するとき' do
174 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
178 @speech.should be_valid
182 @speech.should_not be_valid
186 @speech.should be_valid
190 @speech.should be_valid
193 context 'zを検証するとき' do
195 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
199 @speech.should be_valid
203 @speech.should_not be_valid
207 @speech.should_not be_valid
211 @speech.should_not be_valid
214 context 'tを検証するとき' do
216 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
220 @speech.should be_valid
224 @speech.should_not be_valid
228 @speech.should be_valid
232 @speech.should_not be_valid
235 context 'author_idを検証するとき' do
237 @speech = Factory.build :panel, :author_id => @author.id, :comic_id => @comic.id
240 @speech.author_id = @author.id
241 @speech.should be_valid
244 @speech.author_id = nil
245 @speech.should_not be_valid
248 @speech.author_id = 'a'
249 @speech.should_not be_valid
251 it '存在する絵師でなければ失敗する' do
252 @speech.author_id = 0
253 @speech.should_not be_valid
256 context '全体を検証するとき' do
258 @speech = Factory :panel, :author_id => @author.id, :comic_id => @comic.id