font-size: 12px;
text-align: left;
}
+
+.pettanr-comic-wrapper {
+ margin: 1em auto;
+}
+.pettanr-comic-panel {
+ border-style: solid;
+ border-color: #111;
+ position: relative;
+ margin: 1em 0;
+ overflow: hidden;
+}
+.pettanr-comic-panel img {
+ position: absolute;
+}
+.pettanr-comic-balloon {
+ position: absolute;
+}
+.pettanr-comic-balloon img {
+ width: 100%;
+ height: 100%; }
+.pettanr-comic-balloon p {
+ margin: 0 !important;
+ padding: 0 !important; display: table;
+ position: absolute;
+ top: 0;
+ left: 16.6%;
+ width: 66.6%;
+ height: 100%;
+ *height: auto;
+ *top: 50% !important;
+}
+.pettanr-comic-balloon p span,
+.pettanr-comic-balloon p strong,
+.pettanr-comic-balloon p em,
+.pettanr-comic-balloon p i,
+.pettanr-comic-balloon p samp,
+.pettanr-comic-balloon p code {
+ vertical-align: middle;
+ text-align: center;
+ font-size: 14px;
+ display: table-cell;
+ *display: block;
+ zoom: 1;
+ *position: relative;
+ *top: -50%;
+}
+.pettanr-comic-balloon p strong {
+ font-weight: bold;
+}
+.pettanr-comic-balloon p em,
+.pettanr-comic-balloon p i {
+ font-style: italic;
+}
+.pettanr-comic-balloon p samp,
+.pettanr-comic-balloon p code {
+ font-family: monospace;
+}
'[' + ary.map {|i| i.panel_elements_as_json }.join(',') + ']'
end
+ def licensed_pictures
+ r = {}
+ ((self.panel_pictures || []) + (self.ground_pictures || [])).compact.each do |elm|
+ r[elm.picture_id] = elm.picture unless r[elm.picture_id]
+ end
+ r
+ end
+
def self.visible_count
Panel.count
end
res
end
-=begin\r
+=begin
def self.validate_id ary, pid
ary.map {|v|
if pid
validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
def flip
- res = (self.height < 0 ? '' : 'v') + (self.width == 0 ? '' : 'h')
+ res = (self.height > 0 ? '' : 'v') + (self.width > 0 ? '' : 'h')
res += '/' unless res.empty?
res
end
def filename
- flip + self.resource_picture.filename
+ self.flip + self.picture.filename
end
def url
- '/pictures/' + self.picture.filename
+ '/pictures/' + self.filename
+ end
+
+ def opt_img_tag
+ {:src => self.url, :vPicture => self.id, :width => self.width.abs, :height => self.height.abs, :style => "top:#{self.y}px; left:#{self.x}px; z-index:#{self.z}; "}
+ end
+
+ def tmb_opt_img_tag
+ tw, th = PettanImager.thumbnail_size(self.width.abs, self.height.abs)
+ {:src => self.url, :width => tw, :height => th}
end
def self.default_page_size
'[' + ary.map {|i| i.story_as_json(au) }.join(',') + ']'
end
+ def self.licensed_pictures stories
+ r = {}
+ stories.each do |story|
+ r.merge! story.panel.licensed_pictures
+ end
+ r
+ end
+
def self.new_t comic_id
r = Story.max_t(comic_id)
r.blank? ? 0 : r.to_i + 1
<p class="notice"><%= notice %></p>\r
<p class="alert"><%= alert %></p>\r
<%= link_to 'comics', main_app.comics_path %>\r
-<%= link_to 'stories', main_app.stories_path %>\r
+<%= link_to 'stories', main_app.new_story_path %>\r
<%= link_to 'panels', main_app.panels_path %>\r
<%= link_to 'original_pictures', main_app.original_pictures_path %>\r
<%= link_to 'resource_pictures', main_app.resource_pictures_path %>\r
<th>panel</th>
<th>picture</th>
<th>link</th>
- <th>Width</th>
- <th>Height</th>
- <th>x</th>
- <th>y</th>
- <th>z</th>
+ <th>x, y, z</th>
<th>t</th>
+ <th>WidthxHeight</th>
+ <th>vh</th>
<th>updated_at</th>
</tr>
<tr>
<td><%= panel_picture.id %></td>
<td><%= panel_picture.panel_id %></td>
- <td><%= panel_picture.picture_id %></td>
+ <td><%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %></td>
<td><%= h panel_picture.link %></td>
- <td><%= panel_picture.x %></td>
- <td><%= panel_picture.y %></td>
- <td><%= panel_picture.z %></td>
+ <td><%= panel_picture.x %>, <%= panel_picture.y %>, <%= panel_picture.z %></td>
<td><%= panel_picture.t %></td>
- <td><%= panel_picture.width %></td>
- <td><%= panel_picture.height %></td>
+ <td><%= panel_picture.width %>x<%= panel_picture.height %></td>
+ <td><%= panel_picture.flip %></td>
<td><%= panel_picture.updated_at %></td>
</tr>
<% end %>
<tr>
<th>id</th>
<th>panel</th>
- <th>resource_picture</th>
+ <th>picture</th>
<th>link</th>
<th>x</th>
<th>y</th>
<tr>
<td><%= panel_picture.id %></td>
<td><%= link_to panel_picture.panel_id, :controller => 'panels', :action => :browse, :id => panel_picture.panel_id%></td>
- <td><%= link_to panel_picture.resource_picture_id, :controller => 'resource_pictures', :action => :browse, :id => panel_picture.resource_picture_id %></td>
+ <td><%= link_to panel_picture.picture_id, panel_picture.picture %></td>
<td><%= h panel_picture.link %></td>
<td><%= panel_picture.x %></td>
<td><%= panel_picture.y %></td>
--- /dev/null
+<div class="pettanr-comic-panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;border-style: solid;border-width: <%= panel.border %>px;border-color:black; background-color:white;">
+ <% panel.panel_elements.each do |elm| %>
+ <% case elm.class.to_s %>
+ <% when 'PanelPicture' %>
+ <%= tag(:img, elm.opt_img_tag) %>
+ <% when Balloon %>
+ <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= elm.width -%>px; height:<%= elm.height -%>px; top:<%= elm.y -%>px; left:<%= elm.x -%>px; z-index:<%= elm.z -%>; ">
+ <img src="<%= elm.system_picture.url -%>">
+ <% elm.speeches.each do |speech| %>
+ <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
+ <span><%= h speech.content -%></span>
+ </p>
+ <% end %>
+ </div>
+ <% end ; p elm.class %>
+ <% end %>
+</div>
--- /dev/null
+<table class="no-border">
+ <tr>
+ <td>
+ <%= panel.width %>x<%= panel.height %>
+ </td>
+ <td>
+ <%= panel.updated_at %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+<table class="no-border">
+ <tr>
+ <td>
+ ID:<%= link_to panel.id, panel_path(panel) %>
+ </td>
+ <td>
+ <%= link_to h(panel.author.name), author_path(panel.author) %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+<div class="pettanr-licensed_pictures">
+ <% licensed_pictures.each do |pid, picture| %>
+ <table class="no-border">
+ <tr>
+ <td>
+ <%= link_to(tag(:img, picture.opt_img_tag), picture_path(picture.id)) -%>
+ </td>
+ <td>
+ <%= render picture.credit_template, :picture => picture %>
+ </td>
+ </tr>
+ </table>
+ <% end %>
+</div>
-<div class="pettanr-comic-panel" style="width:<%= @panel.width %>px;height:<%= @panel.height %>px;border-width: <%= @panel.border %>px; background-color:white;">
- <% @panel.panel_elements.each do |elm| %>
- <% if elm.kind_of?(PanelPicture) %>
- <img id="vPicture<%= elm.id -%>" width="<%= elm.width -%>" height="<%= elm.height -%>" style="top:<%= elm.y -%>px; left:<%= elm.x -%>px; z-index:<%= elm.z -%>; " src="<%= elm.url -%>">
- <% end %>
- <% if elm.kind_of?(Balloon) %>
- <div id="vballoon<%= elm.id -%>" class="pettanr-comic-balloon" style="width:<%= elm.width -%>px; height:<%= elm.height -%>px; top:<%= elm.y -%>px; left:<%= elm.x -%>px; z-index:<%= elm.z -%>; ">
- <img src="<%= elm.system_picture.url -%>">
- <% elm.speeches.each do |speech| %>
- <p style="top:<%= speech.y -%>px; left:<%= speech.x -%>px;width:<%= speech.width -%>px; height:<%= speech.height -%>px;">
- <span><%= h speech.content -%></span>
- </p>
- <% end %>
- </div>
- <% end %>
- <% end %>
-</div>
-
-<dl class="dl-table">
-<dt>Width:</dt><dd><%= @panel.width %></dd>
-<dt>Height:</dt><dd><%= @panel.height %></dd>
-</dl>
+<%= render 'panels/header', :panel => panel %>
+<%= render 'panels/body', :panel => panel %>
+<%= render 'panels/footer', :panel => panel %>
+<%= render 'panels/licensed_pictures', :licensed_pictures => panel.licensed_pictures %>
<h1>Listing panels 最近の投稿</h1>
<% @panels.each do |panel| %>
- <div>
-<div class="panel" style="width:<%= panel.width %>px;height:<%= panel.height %>px;overflow:hidden; border:solid black <%= panel.border %>px; background:white;">
- <% panel.panel_pictures.each do |panel_picture| %>
- <div id="vPicture<%= panel_picture.id -%>" class="panel_picture" style="position:relative; top:<%= panel_picture.y -%>px; left:<%= panel_picture.x -%>px; z-index:<%= panel_picture.z -%>; ">
- <img style=" position:absolute; width:<%= panel_picture.width -%>px; height:<%= panel_picture.height -%>px; " src="<%= panel_picture.url -%>">
- </div>
- <% end %>
- <% (panel.speech_balloons || []).each do |sb| %>
- <% (sb.balloons || []).each do |balloon| %>
- <% end %>
- <% (sb.speeches || []).each do |speech| %>
- <% end %>
- <% end %>
-</div>
- <%= h panel.author.name %> <%= panel.updated_at %>
- </div>
+ <%= render 'standard', :panel => panel %>
<% end %>
<%= link_to 'open form', new_panel_path, :remote => true %>
<div id="newpanel">
</div>
<% end %>
<p id="notice"><%= notice %></p>
-<%= render 'standard' %>
+<%= render 'standard', :panel => @panel %>
<%= link_to 'Back', panels_path %>
--- /dev/null
+<table class="no-border">
+ <tr>
+ <td>
+ <%= story.panel.width %>x<%= story.panel.height %>
+ </td>
+ <td>
+ <%= story.panel.updated_at %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+<table class="no-border">
+ <tr>
+ <td>
+ No.<%= link_to story.t, story_path(story) %>
+ </td>
+ <td>
+ <%= link_to h(story.panel.author.name), author_path(story.panel.author) %>
+ </td>
+ <td>
+ ID:<%= link_to story.panel.id, panel_path(story.panel) %>
+ </td>
+ </tr>
+</table>
--- /dev/null
+<div class="pettanr-licensed_pictures">
+ <% licensed_pictures.each do |pid, picture| %>
+ <table class="no-border">
+ <tr>
+ <td>
+ <%= link_to(tag(:img, picture.opt_img_tag), picture_path(picture.id)) -%>
+ </td>
+ <td>
+ <%= render picture.credit_template, :picture => picture %>
+ </td>
+ </tr>
+ </table>
+ <% end %>
+</div>
--- /dev/null
+<%= form_for(@story) do |f| %>
+ <% if @story.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@story.errors.count, "error") %> prohibited this comic from being saved:</h2>
+
+ <ul>
+ <% @story.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.hidden_field :comic_id %>
+ </div>
+ <div class="field">
+ <%= f.number_field :t %>
+ </div>
+ <div class="field">
+ <%= f.hidden_field :panel_id %>
+ </div>
+
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
+<%= button_to 'Destroy', @story.panel, confirm: 'Are you sure?', method: :delete %>
<% @stories.each do |story| %>
<% @story = story %>
- <% @panel = story.panel %>
- <%= render 'panels/standard' %>
- <% if story.author.id == @author.id -%>
- <span>
- t:<%= story.t %>
- </span>
-<%= button_to 'Destroy', @story, confirm: 'Are you sure?', method: :delete %>
- <%= render 'editform' %>
- <%= link_to 'open js', edit_story_path(story), :remote => true %>
- <div id="story-update-<%= @story.id -%>">
+ <%= render 'header', :story => story %>
+ <%= render 'panels/body', :panel => story.panel %>
+ <%= render 'footer', :story => story %>
+ <% if story.own? @author -%>
+ <%= link_to 'move', edit_story_path(story), :remote => true %>
+ <span id="story-update-<%= @story.id -%>">
t
- </div>
+ </span>
<% end -%>
<% end %>
-<% if @comic.author.id == @author.id -%>
+<%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %>
+<h1><%= h @comic.title %></h1>
+<% if @comic.own? @author -%>
<%= link_to 'add panel', new_story_path, :remote => true %>
<div id="story-create">
t
--- /dev/null
+$("#story-update-<%= @story.id -%>").html("<%= escape_javascript(render('editform')) -%>");
- <% @panel = @story.panel %>
- <%= render 'panels/standard' %>
+ <%= render 'panels/standard', :panel => @story.panel %>
<% if @story.author.id == @author.id -%>
<span>
t:<%= @story.t %>
#コマ\r
describe Panel do\r
before do\r
- @admin = FactoryGirl.create :admin
+ @admin = FactoryGirl.create :admin\r
@sp = FactoryGirl.create :system_picture\r
@lg = FactoryGirl.create :license_group\r
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
- @color = FactoryGirl.create :color
+ @color = FactoryGirl.create :color\r
@user = FactoryGirl.create( :user_yas)\r
@author = @user.author\r
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id\r
@panel = FactoryGirl.build :panel, :author_id => @author.id\r
end\r
\r
- context 'オーソドックスなデータのとき' do
- it '下限データが通る' do
- @panel.width = 1
- @panel.height = 1
- @panel.border = 0
- @panel.x = -99999
- @panel.y = -99999
- @panel.z = 1
- @panel.publish = 0
- @panel.should be_valid
- end
- it '上限データが通る' do
- @panel.width = 99999
- @panel.height = 99999
- @panel.border = 99999
- @panel.x = 99999
- @panel.y = 99999
- @panel.z = 99999
- @panel.publish = 99999
- @panel.should be_valid
- end
- end
-
+ context 'オーソドックスなデータのとき' do\r
+ it '下限データが通る' do\r
+ @panel.width = 1\r
+ @panel.height = 1\r
+ @panel.border = 0\r
+ @panel.x = -99999\r
+ @panel.y = -99999\r
+ @panel.z = 1\r
+ @panel.publish = 0\r
+ @panel.should be_valid\r
+ end\r
+ it '上限データが通る' do\r
+ @panel.width = 99999\r
+ @panel.height = 99999\r
+ @panel.border = 99999\r
+ @panel.x = 99999\r
+ @panel.y = 99999\r
+ @panel.z = 99999\r
+ @panel.publish = 99999\r
+ @panel.should be_valid\r
+ end\r
+ end\r
+ \r
context 'widthを検証するとき' do\r
it 'nullなら失敗する' do\r
@panel.width = nil\r
before do\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
end\r
- context '検査対象がnil(ゲスト)のとき' do
- context 'クローズドモードのとき' do
- before do
- MagicNumber['run_mode'] = 1
- end
+ context '検査対象がnil(ゲスト)のとき' do\r
+ context 'クローズドモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 1\r
+ end\r
it '不許可を返す。' do\r
- r = @panel.visible?(nil)
- r.should be_false
+ r = @panel.visible?(nil)\r
+ r.should be_false\r
end\r
end\r
- context 'オープンモードのとき' do
- before do
- MagicNumber['run_mode'] = 0
- end
+ context 'オープンモードのとき' do\r
+ before do\r
+ MagicNumber['run_mode'] = 0\r
+ end\r
it '公開コマなら許可する' do\r
Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(nil)
- r.should be_true
+ r = @panel.visible?(nil)\r
+ r.should be_true\r
end\r
it '非公開コマなら許可しない' do\r
Panel.any_instance.stub(:publish?).and_return(false)\r
- r = @panel.visible?(nil)
- r.should be_false
+ r = @panel.visible?(nil)\r
+ r.should be_false\r
end\r
end\r
end\r
- context '検査対象が作家のとき' do
+ context '検査対象が作家のとき' do\r
it '自分のコマなら許可する' do\r
Panel.any_instance.stub(:own?).and_return(true)\r
Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(@author)
- r.should == true
+ r = @panel.visible?(@author)\r
+ r.should == true\r
end\r
it '他人の非公開コマなら許可しない' do\r
Panel.any_instance.stub(:own?).and_return(false)\r
Panel.any_instance.stub(:publish?).and_return(false)\r
- r = @panel.visible?(@author)
- r.should == false
+ r = @panel.visible?(@author)\r
+ r.should == false\r
end\r
it '他人のコマでも公開なら許可する' do\r
Panel.any_instance.stub(:own?).and_return(false)\r
Panel.any_instance.stub(:publish?).and_return(true)\r
- r = @panel.visible?(@author)
- r.should == true
+ r = @panel.visible?(@author)\r
+ r.should == true\r
end\r
end\r
- context '検査対象がそれ以外のとき' do
+ context '検査対象がそれ以外のとき' do\r
it '不許可を返す。' do\r
- r = @panel.visible?(@admin)
- r.should be_false
+ r = @panel.visible?(@admin)\r
+ r.should be_false\r
end\r
end\r
end\r
r.should eq [@panel]\r
end\r
it '時系列で並んでいる' do\r
- #公開コミックは(他人のコミックであっても)含んでいる
+ #公開コミックは(他人のコミックであっても)含んでいる\r
npl = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
r = Panel.list\r
r.should eq [npl, @panel]\r
pl.should eq [@panel]\r
end\r
end\r
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
+ before do\r
@npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
@npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
@npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
@npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
Panel.stub(:default_page_size).and_return(2)\r
- end
- it '件数0は全件(5件)を返す' do
- r = Panel.list 5, 0
- r.should have(5).items
- end
- end
+ end\r
+ it '件数0は全件(5件)を返す' do\r
+ r = Panel.list 5, 0\r
+ r.should have(5).items \r
+ end\r
+ end\r
end\r
describe '一覧取得オプションに於いて' do\r
it 'includeキーを含んでいる' do\r
pl = Panel.mylist @author\r
pl.should eq [npl, @panel]\r
end\r
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
+ before do\r
@npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
@npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
@npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
@npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
- end
+ end\r
it '通常は2件を返す' do\r
pl = Panel.list 1, 2\r
pl.should have(2).items \r
pl = Panel.mylist @author, 3, 2\r
pl.should eq [@panel]\r
end\r
- end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
+ end\r
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
+ before do\r
@npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
@npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
@npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
@npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
Author.stub(:default_panel_page_size).and_return(2)\r
- end
- it '通常は全件(5件)を返す' do
- r = Panel.mylist @author, 5, 0
- r.should have(5).items
- end
- end
+ end\r
+ it '通常は全件(5件)を返す' do\r
+ r = Panel.mylist @author, 5, 0\r
+ r.should have(5).items \r
+ end\r
+ end\r
end\r
\r
describe '単体取得に於いて' do\r
it '単体取得オプションを利用している' do\r
Panel.stub(:show_opt).with(any_args).and_return({})\r
Panel.should_receive(:show_opt).with(any_args).exactly(1)\r
- r = Panel.show @panel.id, @author
+ r = Panel.show @panel.id, @author\r
end\r
it '閲覧許可を問い合わせている' do\r
Panel.any_instance.stub(:visible?).with(any_args).and_return(true)\r
Panel.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
- r = Panel.show @panel.id, @author
+ r = Panel.show @panel.id, @author\r
end\r
end\r
it '指定のコマを返す' do\r
it '単体取得オプションを利用している' do\r
Panel.stub(:show_opt).with(any_args).and_return({})\r
Panel.should_receive(:show_opt).with(any_args).exactly(1)\r
- r = Panel.edit @panel.id, @author
+ r = Panel.edit @panel.id, @author\r
end\r
it '所持判定を問い合わせている' do\r
Panel.any_instance.stub(:own?).with(any_args).and_return(true)\r
Panel.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
- r = Panel.edit @panel.id, @author
+ r = Panel.edit @panel.id, @author\r
end\r
end\r
it '指定のコマを返す' do\r
j.first.has_key?('p').should be_true\r
end\r
end\r
+ \r
+ describe 'ライセンス素材に於いて' do\r
+ before do\r
+ #コマを作成しておく。\r
+ @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
+ @p2 = FactoryGirl.create :picture, :original_picture_id => @op2.id, :license_id => @license.id, :artist_id => @artist.id\r
+ @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height, :picture_id => @p.id\r
+ @sb = @panel.speech_balloons.create(\r
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
+ )\r
+ @gc = @panel.ground_colors.create(\r
+ FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+ )\r
+ @gp = @panel.ground_pictures.create(\r
+ FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p2.id)\r
+ )\r
+ @pc = @panel.panel_colors.create(\r
+ FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
+ )\r
+ @panel.reload\r
+ end\r
+ context '事前チェック' do\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ end\r
+ it '連想配列(値は実素材、キーは実素材id)を返している' do\r
+ r = @panel.licensed_pictures\r
+ r.is_a?(Hash).should be_true\r
+ r.should have(2).items\r
+ r[@pp.picture_id].should eq @p\r
+ r[@gp.picture_id].should eq @p2\r
+ end\r
+ end\r
+ \r
describe '検証値収集に於いて' do\r
context 'つつがなく終わるとき' do\r
it '第一パラメータで指定された配列中から第二引数のカラム値を収集している' do\r
describe '保存に於いて' do\r
before do\r
@attr = FactoryGirl.attributes_for :panel\r
- @panel = Panel.new
- @panel.supply_default
+ @panel = Panel.new\r
+ @panel.supply_default\r
end\r
context 'つつがなく終わるとき' do\r
before do\r
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
@other_user = FactoryGirl.create( :user_yas)
@other_author = @other_user.author
- @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
- @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
- @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
- @sbt = FactoryGirl.create :speech_balloon_template\r
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+ @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+ @sbt = FactoryGirl.create :speech_balloon_template
end
describe '検証に於いて' do
end
end
- describe '閲覧許可に於いて' do\r
- before do\r
+ describe '閲覧許可に於いて' do
+ before do
@comic = FactoryGirl.create :comic, :author_id => @author.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
- end\r
+ end
context '検査対象がnil(ゲスト)のとき' do
context 'クローズドモードのとき' do
before do
MagicNumber['run_mode'] = 1
end
- it '不許可を返す。' do\r
+ it '不許可を返す。' do
r = @story.visible?(nil)
r.should be_false
- end\r
- end\r
+ end
+ end
context 'オープンモードのとき' do
before do
MagicNumber['run_mode'] = 0
end
- it '公開コミックのストーリーなら許可する' do\r
- Comic.any_instance.stub(:visible?).with(nil).and_return(true)\r
+ it '公開コミックのストーリーなら許可する' do
+ Comic.any_instance.stub(:visible?).with(nil).and_return(true)
r = @story.visible?(nil)
r.should be_true
- end\r
- it '非公開コミックのストーリーなら許可しない' do\r
- Comic.any_instance.stub(:visible?).with(nil).and_return(false)\r
+ end
+ it '非公開コミックのストーリーなら許可しない' do
+ Comic.any_instance.stub(:visible?).with(nil).and_return(false)
r = @story.visible?(nil)
r.should be_false
- end\r
- end\r
- end\r
+ end
+ end
+ end
context '検査対象が作家のとき' do
- it '自分のコミックのストーリーなら許可する' do\r
- Comic.any_instance.stub(:own?).with(@author).and_return(true)\r
- Comic.any_instance.stub(:visible?).with(@author).and_return(true)\r
+ it '自分のコミックのストーリーなら許可する' do
+ Comic.any_instance.stub(:own?).with(@author).and_return(true)
+ Comic.any_instance.stub(:visible?).with(@author).and_return(true)
r = @story.visible?(@author)
r.should == true
- end\r
- it '他人の非公開コミックのストーリーなら許可しない' do\r
- Comic.any_instance.stub(:own?).with(@other_author).and_return(false)\r
- Comic.any_instance.stub(:visible?).with(@other_author).and_return(false)\r
+ end
+ it '他人の非公開コミックのストーリーなら許可しない' do
+ Comic.any_instance.stub(:own?).with(@other_author).and_return(false)
+ Comic.any_instance.stub(:visible?).with(@other_author).and_return(false)
r = @story.visible?(@other_author)
r.should == false
- end\r
- it '他人のコミックのストーリーでも公開なら許可する' do\r
- Comic.any_instance.stub(:own?).with(@other_author).and_return(false)\r
- Comic.any_instance.stub(:visible?).with(@other_author).and_return(true)\r
+ end
+ it '他人のコミックのストーリーでも公開なら許可する' do
+ Comic.any_instance.stub(:own?).with(@other_author).and_return(false)
+ Comic.any_instance.stub(:visible?).with(@other_author).and_return(true)
r = @story.visible?(@other_author)
r.should == true
- end\r
- end\r
+ end
+ end
context '検査対象がそれ以外のとき' do
- it '不許可を返す。' do\r
+ it '不許可を返す。' do
r = @story.visible?(@admin)
r.should be_false
- end\r
- end\r
- end\r
- \r
+ end
+ end
+ end
+
describe '一覧取得に於いて' do
before do
@comic = FactoryGirl.create :comic, :author_id => @author.id
@hcomic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0
@hpanel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
end
- context 'つつがなく終わるとき' do\r
- it '一覧取得オプションを利用している' do\r
- Story.stub(:list_opt).with(any_args).and_return({})\r
- Story.should_receive(:list_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ Story.stub(:list_opt).with(any_args).and_return({})
+ Story.should_receive(:list_opt).with(any_args).exactly(1)
r = Story.mylist @author
- end\r
- end\r
+ end
+ end
it 'リストを返す' do
s = Story.mylist @author
s.should eq [@story]
@story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
@story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
@story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
- Author.stub(:default_story_size).and_return(2)\r
+ Author.stub(:default_story_size).and_return(2)
end
it '通常は全件(5件)を返す' do
r = Story.mylist @author, 5, 0
@panel = FactoryGirl.create :panel, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
end
- context 'つつがなく終わるとき' do\r
- it '単体取得オプションを利用している' do\r
- Story.stub(:show_opt).with(any_args).and_return({})\r
- Story.should_receive(:show_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '単体取得オプションを利用している' do
+ Story.stub(:show_opt).with(any_args).and_return({})
+ Story.should_receive(:show_opt).with(any_args).exactly(1)
r = Story.show @story.id, @author
- end\r
- it '閲覧許可を問い合わせている' do\r
- Story.any_instance.stub(:visible?).with(@author).and_return(true)\r
- Story.any_instance.should_receive(:visible?).with(@author).exactly(1)\r
+ end
+ it '閲覧許可を問い合わせている' do
+ Story.any_instance.stub(:visible?).with(@author).and_return(true)
+ Story.any_instance.should_receive(:visible?).with(@author).exactly(1)
r = Story.show @story.id, @author
- end\r
- end\r
+ end
+ end
it '指定のストーリーを返す' do
l = Story.show @story.id, @author
l.should eq @story
@panel = FactoryGirl.create :panel, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
end
- context 'つつがなく終わるとき' do\r
- it '単体取得オプションを利用している' do\r
- Story.stub(:show_opt).with(any_args).and_return({})\r
- Story.should_receive(:show_opt).with(any_args).exactly(1)\r
+ context 'つつがなく終わるとき' do
+ it '単体取得オプションを利用している' do
+ Story.stub(:show_opt).with(any_args).and_return({})
+ Story.should_receive(:show_opt).with(any_args).exactly(1)
r = Story.edit @story.id, @author
- end\r
- it '所持判定を問い合わせている' do\r
- Story.any_instance.stub(:own?).with(any_args).and_return(true)\r
- Story.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+ end
+ it '所持判定を問い合わせている' do
+ Story.any_instance.stub(:own?).with(any_args).and_return(true)
+ Story.any_instance.should_receive(:own?).with(any_args).exactly(1)
r = Story.edit @story.id, @author
- end\r
- end\r
+ end
+ end
it '指定のストーリーを返す' do
l = Story.edit @story.id, @author
l.should eq @story
end
describe 'ストーリーのjson出力に於いて' do
- before do\r
- #コマを作成しておく。\r
- @panel = FactoryGirl.create :panel, :author_id => @author.id\r
- @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
- )\r
- @gc = @panel.ground_colors.create(\r
- FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
- )\r
- @gp = @panel.ground_pictures.create(\r
- FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
- )\r
- @pc = @panel.panel_colors.create(\r
- FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
- )\r
- @panel.reload\r
+ before do
+ #コマを作成しておく。
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
+ @sb = @panel.speech_balloons.create(
+ FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
+ )
+ @gc = @panel.ground_colors.create(
+ FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)
+ )
+ @gp = @panel.ground_pictures.create(
+ FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
+ )
+ @pc = @panel.panel_colors.create(
+ FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)
+ )
+ @panel.reload
@comic = FactoryGirl.create :comic, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
- end\r
+ end
context '事前チェックする' do
- before do\r
+ before do
Panel.any_instance.stub(:elements).and_return('{}')
- end\r
- it 'コマ要素のjson出力を依頼している' do\r
+ end
+ it 'コマ要素のjson出力を依頼している' do
Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
- Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)\r
+ Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)
r = @story.story_as_json @author
- end\r
- end\r
- it 'json textを返している' do\r
- r = JSON.parse @story.story_as_json(@author)\r
- r.is_a?(Hash).should be_true\r
- end\r
- it 'comic,author,panel,コマ要素を含んでいる' do\r
- r = JSON.parse @story.story_as_json(@author)\r
- r.has_key?('comic').should be_true\r
- r['comic'].has_key?('author').should be_true\r
- r.has_key?('author').should be_true\r
- r.has_key?('panel').should be_true\r
- r['panel'].has_key?('author').should be_true\r
- end\r
+ end
+ end
+ it 'json textを返している' do
+ r = JSON.parse @story.story_as_json(@author)
+ r.is_a?(Hash).should be_true
+ end
+ it 'comic,author,panel,コマ要素を含んでいる' do
+ r = JSON.parse @story.story_as_json(@author)
+ r.has_key?('comic').should be_true
+ r['comic'].has_key?('author').should be_true
+ r.has_key?('author').should be_true
+ r.has_key?('panel').should be_true
+ r['panel'].has_key?('author').should be_true
+ end
context 'コマ閲覧許可のとき' do
- before do\r
+ before do
Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
- end\r
- it 'コマ要素にコマ要素を追加している' do\r
- r = JSON.parse @story.story_as_json(@author)\r
- r['panel'].has_key?('elements').should be_true\r
- r['panel']['elements'].should_not be_empty\r
- end\r
- end\r
+ end
+ it 'コマ要素にコマ要素を追加している' do
+ r = JSON.parse @story.story_as_json(@author)
+ r['panel'].has_key?('elements').should be_true
+ r['panel']['elements'].should_not be_empty
+ end
+ end
context 'コマ閲覧不許可のとき' do
- before do\r
+ before do
Panel.any_instance.stub(:visible?).with(any_args).and_return(false)
- end\r
- it 'コマ要素にデータを含ませない' do\r
- r = JSON.parse @story.story_as_json(@author)\r
- r['panel'].has_key?('elements').should be_false\r
- end\r
- end\r
+ end
+ it 'コマ要素にデータを含ませない' do
+ r = JSON.parse @story.story_as_json(@author)
+ r['panel'].has_key?('elements').should be_false
+ end
+ end
end
- describe 'ストーリーリストのjson出力に於いて' do\r
- before do\r
- @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ describe 'ストーリーリストのjson出力に於いて' do
+ before do
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
@comic = FactoryGirl.create :comic, :author_id => @author.id
@story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
- Story.any_instance.stub(:story_as_json).with(@author).and_return('{"s": 5}')\r
- end\r
- context 'つつがなく終わるとき' do\r
- it 'ストーリーのjson出力を依頼している' do\r
- Story.any_instance.should_receive(:story_as_json).with(@author).exactly(1)\r
- r = Story.list_as_json_text [@story], @author\r
- end\r
- end\r
- it 'json textを返している' do\r
- r = Story.list_as_json_text [@story], @author\r
- j = JSON.parse r\r
- j.is_a?(Array).should be_true\r
- end\r
- it 'ストーリーを含んでいる' do\r
- r = Story.list_as_json_text [@story], @author\r
+ Story.any_instance.stub(:story_as_json).with(@author).and_return('{"s": 5}')
+ end
+ context 'つつがなく終わるとき' do
+ it 'ストーリーのjson出力を依頼している' do
+ Story.any_instance.should_receive(:story_as_json).with(@author).exactly(1)
+ r = Story.list_as_json_text [@story], @author
+ end
+ end
+ it 'json textを返している' do
+ r = Story.list_as_json_text [@story], @author
+ j = JSON.parse r
+ j.is_a?(Array).should be_true
+ end
+ it 'ストーリーを含んでいる' do
+ r = Story.list_as_json_text [@story], @author
j = JSON.parse r
- j.first.has_key?('s').should be_true\r
- end\r
+ j.first.has_key?('s').should be_true
+ end
+ end
+
+ describe 'ライセンス素材に於いて' do
+ before do
+ #コマを作成しておく。
+ @op2 = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @p2 = FactoryGirl.create :picture, :original_picture_id => @op2.id, :license_id => @license.id, :artist_id => @artist.id
+ @rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 0, :width => @p.width, :height => @p.height, :picture_id => @p.id
+ @panel.reload
+ @panel2 = FactoryGirl.create :panel, :author_id => @author.id
+ @pp2= FactoryGirl.create :panel_picture, :panel_id => @panel2.id, :t => 0, :width => @p2.width, :height => @p2.height, :picture_id => @p2.id
+ @panel2.reload
+
+ @comic = FactoryGirl.create :comic, :author_id => @author.id
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+ @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id
+ end
+ context '事前チェック' do
+ end
+ context 'つつがなく終わるとき' do
+ end
+ it '連想配列(値は実素材、キーは実素材id)を返している' do
+ r = Story.licensed_pictures [@story, @story2]
+ r.is_a?(Hash).should be_true
+ r.should have(2).items
+ r[@pp.picture_id].should eq @p
+ r[@pp2.picture_id].should eq @p2
+ end
end
- \r
+
describe 't補充値に於いて' do
before do
@comic = FactoryGirl.create :comic, :author_id => @author.id