before_validation :valid_encode
def valid_encode
- ['title'].each do |a|
+ ['title', 'description'].each do |a|
next if attributes[a] == nil
raise Pettanr::BadRequest unless attributes[a].valid_encoding?
end
validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
validates :publish, :presence => true, :numericality => true
+ before_validation :valid_encode
+
+ def valid_encode
+ ['caption'].each do |a|
+ next if attributes[a] == nil
+ raise Pettanr::BadRequest unless attributes[a].valid_encoding?
+ end
+ end
+
def supply_default
self.border = 2
self.publish = 0
<%= f.text_field :title %>
</div>
<div class="field">
+ <%= f.label :description %><br />
+ <%= f.text_area :description %>
+ </div>
+ <div class="field">
<%= f.label :visible %><br />
<%= f.collection_select :visible, t_select_items(MagicNumber['comic_visible_items']), :last, :first, :html => {:selected => @comic.visible} %>
</div>
<% end %>
</td>
</tr>
+<tr>
+ <td colspan="4">
+ <%= h(truncate(comic.description, :length => 40)) %>
+ </td>
+</tr>
:updated => comic.updated_at
) do |item|
item.title(comic.title)
- item.content(comic.title, :type => 'html')
+ item.content(comic.description, :type => 'html')
item.author {|author| author.name(comic.author.name)}
end
end
xml.title comic.title
xml.link comic_url(comic)
xml.guid comic_url(comic)
- xml.description comic.title
+ xml.description comic.description
xml.pubDate comic.updated_at.to_formatted_s(:rfc822)
xml.dc :creator, comic.author.name
end
</p>
<p>
+ <b><%= t_m 'Comic.description' -%>:</b>
+ <%= h(@comic.description) %>
+</p>
+
+<p>
<b><%= t_m 'Comic.visible' -%>:</b>
<%= t_selected_item('comic_visible_items', @comic.visible) %>
</p>
+<b><%= t_m 'Panel.caption' -%>:</b>
+<%= h(panel.caption) %>
<%= render 'panels/body', :panel => panel, :author => author %>
<%= render 'panels/footer', :panel => panel, :author => author %>
<%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
<%= render 'standard', :panel => panel, :author => @author %>
<% end %>
<%= link_to t('panels.new.title'), new_panel_path %>
-<noscript>
- <% @panels.each do |panel| %>
- <%= raw panel.scenario %>
- <% end %>
-</noscript>
authentication_token: 認証トークン
comic:
title: タイトル
+ description: あらすじ
visible: 公開
author_id: 作家
created_at: 更新
x: X
y: Y
z: 重なり
+ caption: 要約
publish: 公開
author_id: 作家
panel_picture:
--- /dev/null
+class AddDescriptionOnComics < ActiveRecord::Migration
+ def up
+ add_column :comics, :description, :string
+ end
+
+ def down
+ remove_column :comics, :description
+ end
+end
factory :comic, :class => Comic do |comic|
comic.title "comic"
+ comic.description 'comic description'
comic.visible 1
end
panel.border 1
panel.width 100
panel.height 300
+ panel.caption 'panel caption'
panel.publish 1
panel.author_id 1
end
}.should raise_error(Pettanr::BadRequest)
end
end
+
+ context 'descriptionを検証するとき' do
+ it 'Shift JISなら失敗する' do
+ @comic.description = "\x83G\x83r\x83]\x83D"
+ lambda{
+ @comic.valid_encode
+ }.should raise_error(Pettanr::BadRequest)
+ end
+ end
end
describe 'デフォルト値補充に於いて' do
end\r
end\r
\r
+ describe '文字コード検証に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.build :panel, :author_id => @author.id\r
+ end\r
+ \r
+ context 'captionを検証するとき' do\r
+ it 'Shift JISなら失敗する' do\r
+ @panel.caption = "\x83G\x83r\x83]\x83D"\r
+ lambda{\r
+ @panel.valid_encode\r
+ }.should raise_error(Pettanr::BadRequest)\r
+ end\r
+ end\r
+ \r
+ end\r
+ \r
describe 'デフォルト値補充に於いて' do\r
before do\r
@panel = FactoryGirl.build :panel, :author_id => @author.id\r