before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
before_filter :authenticate_author, :only => [:edit, :update]
else
- before_filter :authenticate_reader, :only => [:index, :show, :comics, :stories, :panels]
+ before_filter :authenticate_reader, :only => [:index, :show, :comics, :stories, :panels, :panel_pictures, :ground_pictures, :ground_colors, :panel_colors]
before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
before_filter :authenticate_author, :only => [:edit, :update]
end
end
end
+ def panel_pictures
+ @au = Author.show(params[:id], [@user, @admin])
+
+ @page = Author.page params[:page]
+ @page_size = Author.panel_picture_page_size params[:page_size]
+ @panel_pictures = PanelPicture.himlist(@au, @page, @page_size)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @panel_pictures.to_json(PanelPicture.list_json_opt) }
+ end
+ end
+
+ def ground_pictures
+ @au = Author.show(params[:id], [@user, @admin])
+
+ @page = Author.page params[:page]
+ @page_size = Author.ground_picture_page_size params[:page_size]
+ @ground_pictures = GroundPicture.himlist(@au, @page, @page_size)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @ground_pictures.to_json(GroundPicture.list_json_opt) }
+ end
+ end
+
+ def ground_colors
+ @au = Author.show(params[:id], [@user, @admin])
+
+ @page = Author.page params[:page]
+ @page_size = Author.ground_color_page_size params[:page_size]
+ @ground_colors = GroundColor.himlist(@au, @page, @page_size)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @ground_colors.to_json(GroundColor.list_json_opt) }
+ end
+ end
+
+ def panel_colors
+ @au = Author.show(params[:id], [@user, @admin])
+
+ @page = Author.page params[:page]
+ @page_size = Author.panel_color_page_size params[:page_size]
+ @panel_colors = PanelColor.himlist(@au, @page, @page_size)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @panel_colors.to_json(PanelColor.list_json_opt) }
+ end
+ end
+
def count
@au = {:count => Author.visible_count}
respond_to do |format|
GroundColor.find(:all, opt)
end
- def self.list_opt
- {:include => {:panel => {:author => {}}, :color => {} }}
- end
-
- def self.list_json_opt
- {:include => {:panel => {:include => {:author => {}}}, :color => {} }}
- end
-
def self.mylist au, page = 1, page_size = Author.default_ground_color_page_size
opt = {}
opt.merge!(self.list_opt)
GroundColor.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_ground_color_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'ground_colors.updated_at desc'})
+ GroundColor.find(:all, opt)
+ end
+
+ def self.list_opt
+ {:include => {:panel => {:author => {}}, :color => {} }}
+ end
+
+ def self.list_json_opt
+ {:include => {:panel => {:include => {:author => {}}}, :color => {} }}
+ end
+
def self.show cid, roles
opt = {}
opt.merge!(GroundColor.show_opt)
GroundPicture.find(:all, opt)
end
- def self.list_opt
- {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
- end
-
- def self.list_json_opt
- {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
- end
-
def self.mylist au, page = 1, page_size = Author.default_ground_picture_page_size
opt = {}
opt.merge!(self.list_opt)
GroundPicture.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_ground_picture_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'ground_pictures.updated_at desc'})
+ GroundPicture.find(:all, opt)
+ end
+
+ def self.list_opt
+ {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
+ end
+
+ def self.list_json_opt
+ {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
+ end
+
def self.show cid, au
opt = {}
opt.merge!(GroundPicture.show_opt)
PanelColor.find(:all, opt)
end
- def self.list_opt
- {:include => {:panel => {:author => {}} }}
- end
-
- def self.list_json_opt
- {:include => {:panel => {:include => {:author => {}}} }}
- end
-
def self.mylist au, page = 1, page_size = Author.default_panel_color_page_size
opt = {}
opt.merge!(PanelColor.list_opt)
PanelColor.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_panel_color_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'panel_colors.updated_at desc'})
+ PanelColor.find(:all, opt)
+ end
+
+ def self.list_opt
+ {:include => {:panel => {:author => {}} }}
+ end
+
+ def self.list_json_opt
+ {:include => {:panel => {:include => {:author => {}}} }}
+ end
+
def self.show cid, roles
opt = {}
opt.merge!(PanelColor.show_opt)
PanelPicture.find(:all, opt)
end
- def self.list_opt
- {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
- end
-
- def self.list_json_opt
- {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
- end
-
def self.mylist au, page = 1, page_size = Author.default_panel_picture_page_size
opt = {}
opt.merge!(PanelPicture.list_opt)
PanelPicture.find(:all, opt)
end
+ def self.himlist au, page = 1, page_size = Author.default_panel_picture_page_size
+ opt = {}
+ opt.merge!(self.list_opt)
+ opt.merge!({:limit => page_size, :offset => (page -1) * page_size}) if page_size > 0
+ opt.merge!({:conditions => ['panels.author_id = ? and panels.publish > 0', au.id], :order => 'panel_pictures.updated_at desc'})
+ PanelPicture.find(:all, opt)
+ end
+
+ def self.list_opt
+ {:include => {:panel => {:author => {}}, :picture => {:artist => {}, :license => {}}}}
+ end
+
+ def self.list_json_opt
+ {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
+ end
+
def self.show cid, au
opt = {}
opt.merge!(PanelPicture.show_opt)
--- /dev/null
+<h1><%= t '.title' -%></h1>
+
+<table>
+ <tr>
+ <th><%= t_m 'GroundColor.panel_id' -%></th>
+ <th><%= t_m 'GroundColor.color_id' -%></th>
+ <th><%= t_m 'GroundColor.z' -%></th>
+ <th><%= t_m 'GroundColor.created_at' -%></th>
+ <th><%= t_m 'GroundColor.updated_at' -%></th>
+ </tr>
+
+ <% @ground_colors.each do |ground_color| %>
+ <tr>
+ <td><%= link_to gc.panel_id, panel_path(gc.panel_id) %></td>
+ <td style="color: #<%= format("%06x", gc.color.code ^ 0xffffff) -%>; background-color: #<%= format("%06x", gc.color.code) -%>;"><%= h gc.color.name %></td>
+ <td><%= gc.z %></td>
+ <td><%= distance_of_time_in_words_to_now gc.created_at %></td>
+ <td><%= distance_of_time_in_words_to_now gc.updated_at %></td>
+ </tr>
+ <% end -%>
+</table>
--- /dev/null
+<h1><%= t '.title' -%></h1>
+
+<table>
+ <tr>
+ <th><%= t_m 'GroundPicture.panel_id' -%></th>
+ <th><%= t_m 'GroundPicture.picture_id' -%></th>
+ <th><%= -%></th>
+ <th><%= t_m 'GroundPicture.z' -%></th>
+ <th><%= t_m 'GroundPicture.repeat' -%></th>
+ <th><%= t_m 'GroundPicture.x' -%></th>
+ <th><%= t_m 'GroundPicture.y' -%></th>
+ <th><%= t_m 'GroundPicture.created_at' -%></th>
+ <th><%= t_m 'GroundPicture.updated_at' -%></th>
+ </tr>
+
+ <% @ground_pictures.each do |ground_picture| %>
+ <tr>
+ <td><%= link_to ground_picture.panel_id, panel_path(ground_picture.panel_id) %></td>
+ <% if ground_picture.picture.showable? @author %>
+ <td><%= link_to(tag(:img, ground_picture.picture.tmb_opt_img_tag), ground_picture) -%></td>
+ <td><%= render ground_picture.picture.credit_template, :picture => ground_picture.picture %></td>
+ <% else %>
+ <td>
+ <%= link_to(tag(:img, ground_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), ground_picture) -%>
+ </td>
+ <td></td>
+ <% end %>
+ <td><%= ground_picture.z %></td>
+ <td><%= ground_picture.repeat %><%= MagicNumber['ground_picture_repeat_items'][ground_picture.repeat] %></td>
+ <td><%= ground_picture.x %></td>
+ <td><%= ground_picture.y %></td>
+ <td><%= distance_of_time_in_words_to_now ground_picture.created_at %></td>
+ <td><%= distance_of_time_in_words_to_now ground_picture.updated_at %></td>
+ </tr>
+ <% end %>
+</table>
--- /dev/null
+<h1><%= t '.title' -%></h1>
+
+<table>
+ <tr>
+ <th><%= t_m 'PanelColor.panel_id' -%></th>
+ <th><%= t_m 'PanelColor.code' -%></th>
+ <th><%= t_m 'PanelColor.z' -%></th>
+ <th><%= t_m 'PanelColor.created_at' -%></th>
+ <th><%= t_m 'PanelColor.updated_at' -%></th>
+ </tr>
+
+ <% @panel_colors.each do |panel_color| %>
+ <tr>
+ <td><%= link_to panel_color.panel_id, panel_path(panel_color.panel_id) %></td>
+ <td style="color: #<%= format("%06x", panel_color.code ^ 0xffffff) -%>; background-color: #<%= format("%06x", panel_color.code) -%>;"><%= format("%06x", panel_color.code ^ 0xffffff) %></td>
+ <td><%= panel_color.z %></td>
+ <td><%= distance_of_time_in_words_to_now panel_color.created_at %></td>
+ <td><%= distance_of_time_in_words_to_now panel_color.updated_at %></td>
+ </tr>
+ <% end %>
+</table>
--- /dev/null
+<h1><%= t '.title' -%></h1>
+
+
+<table>
+ <tr>
+ <th><%= t_m 'PanelPicture.picture_id' -%></th>
+ <th><%= -%></th>
+ <th><%= t_m 'PanelPicture.panel_id' -%></th>
+ <th><%= t_m 'PanelPicture.link' -%></th>
+ <th><%= t_m 'PanelPicture.caption' -%></th>
+ <th><%= t_m 'PanelPicture.updated_at' -%></th>
+ </tr>
+
+ <% @panel_pictures.each do |panel_picture| %>
+ <tr>
+ <% if panel_picture.picture.showable? @author %>
+ <td>
+ <%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture) %>
+ </td>
+ <td><%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %></td>
+ <% else %>
+ <td>
+ <%= link_to(tag(:img, panel_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), panel_picture) -%>
+ </td>
+ <td></td>
+ <% end %>
+ <td><%= link_to panel_picture.panel.id, panel_path(panel_picture.panel) %></td>
+ <td><%= link_to h(truncate(panel_picture.link, :length => 12)), panel_picture.link %></td>
+ <td><%= h(truncate(panel_picture.caption, :length => 12)) %></td>
+ <td><%= distance_of_time_in_words_to_now panel_picture.updated_at %></td>
+ </tr>
+ <% end %>
+</table>
<%= link_to t('authors.show.to_panels'), panels_author_path(@au) %>
</p>
+<p>
+ <%= link_to t('authors.show.to_panel_pictures'), panel_pictures_author_path(@au) %>
+</p>
+
+<p>
+ <%= link_to t('authors.show.to_ground_pictures'), ground_pictures_author_path(@au) %>
+</p>
+
+<p>
+ <%= link_to t('authors.show.to_ground_colors'), ground_colors_author_path(@au) %>
+</p>
+
+<p>
+ <%= link_to t('authors.show.to_panel_colors'), panel_colors_author_path(@au) %>
+</p>
+
<% if @au.own?(@author) %>
<%= link_to t('link.edit'), edit_author_path(@au) %>
<% end %>
to_comics: 最近更新したコミック
to_stories: 最近更新したストーリー
to_panels: 最近更新したコマ
+ to_panel_pictures: 最近コマで使ったコマ絵
+ to_ground_pictures: 最近コマで使った絵地
+ to_ground_colors: 最近コマで使った選択色地
+ to_panel_colors: 最近コマで使った指定色地
comics:
title: 最近更新したコミック
stories:
title: 最近更新したストーリー
panels:
title: 最近更新したコマ
+ panel_pictures:
+ title: 最近更新したコマ絵
+ ground_pictures:
+ title: 最近更新した絵地
+ ground_colors:
+ title: 最近更新した選択色地
+ panel_colors:
+ title: 最近更新した指定色地
new:
title: 作家登録
announce: 作家登録してください
get :comics
get :stories
get :panels
+ get :panel_pictures
+ get :ground_pictures
+ get :ground_colors
+ get :panel_colors
end
end
resources :artists do
get :resource_pictures
end
end
- resources :speech_balloon_templates do
- collection do
- get :index
- get :show
- get :list
- end
- member do
- get :browse
- delete :destroy
+ resources :comics do
+ new do
+ get :new
end
- end
- resources :speeches do
collection do
get :index
get :show
+ get :count
+ post :create
get :list
end
member do
+ get :edit
+ put :update
+ delete :destroy
get :browse
end
end
- resources :balloons do
+ resources :stories do
+ new do
+ get :new
+ end
collection do
get :index
get :show
+ post :create
get :list
end
member do
+ get :comic
+ put :update
+ delete :destroy
get :browse
end
end
- resources :speech_balloons do
+ resources :panels do
+ new do
+ get :new
+ end
collection do
get :index
get :show
+ get :count
+ post :create
get :list
end
member do
+ put :update
+ delete :destroy
get :browse
end
end
get :browse
end
end
- resources :pictures do
- collection do
- get :show
- get :credit
- get :search
- get :list
- end
- member do
- get :credit
- get :browse
- end
- end
- resources :resource_pictures do
+ resources :speech_balloons do
collection do
get :index
get :show
- get :new
- post :create
- get :count
get :list
end
member do
- delete :destroy
- get :credit
get :browse
end
end
- resources :original_pictures do
- new do
- get :new
- end
+ resources :balloons do
collection do
get :index
get :show
- post :create
get :list
end
member do
- get :edit
- put :update
- delete :destroy
- get :history
get :browse
end
end
- resources :original_picture_license_groups do
- new do
- post :new
- end
- collection do
- post :create
- end
- end
- resources :colors do
+ resources :speeches do
collection do
get :index
get :show
get :browse
end
end
- resources :panels do
+ resources :original_pictures do
new do
get :new
end
collection do
get :index
get :show
- get :count
post :create
get :list
end
member do
+ get :edit
put :update
delete :destroy
+ get :history
get :browse
end
end
- resources :stories do
- new do
- get :new
- end
+ resources :resource_pictures do
collection do
get :index
get :show
+ get :new
post :create
+ get :count
get :list
end
member do
- get :comic
- put :update
delete :destroy
+ get :credit
get :browse
end
end
- resources :comics do
- new do
- get :new
+ resources :pictures do
+ collection do
+ get :show
+ get :credit
+ get :search
+ get :list
+ end
+ member do
+ get :credit
+ get :browse
end
+ end
+ resources :speech_balloon_templates do
collection do
get :index
get :show
- get :count
- post :create
get :list
end
member do
- get :edit
- put :update
- delete :destroy
get :browse
+ delete :destroy
end
end
resources :licenses do
delete :destroy
end
end
+ resources :original_picture_license_groups do
+ new do
+ post :new
+ end
+ collection do
+ post :create
+ end
+ end
+ resources :colors do
+ collection do
+ get :index
+ get :show
+ get :list
+ end
+ member do
+ get :browse
+ end
+ end
resources :system_pictures do
collection do
get :index
end
end
+ describe '対象作家のコマ絵一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @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
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
+ PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
+ sign_in @user
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :panel_pictures, :id => @other_author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :panel_pictures, :id => @other_author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :panel_pictures, :id => @other_author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :panel_pictures, :id => @other_author.id
+ assigns(:page_size).should eq Author.default_panel_picture_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :panel_pictures, :id => @other_author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.panel_picture_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :panel_pictures, :id => @other_author.id, :page_size => 0
+ assigns(:page_size).should eq Author.default_panel_picture_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ it '作家モデルに単体取得を問い合わせている' do
+ Author.should_receive(:show).exactly(1)
+ get :panel_pictures, :id => @other_author.id
+ end
+ it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
+ PanelPicture.should_receive(:himlist).exactly(1)
+ get :panel_pictures, :id => @other_author.id
+ end
+ it '@panel_picturesにリストを取得している' do
+ get :panel_pictures, :id => @other_author.id
+ assigns(:panel_pictures).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'panel_picturesテンプレートを描画する' do
+ get :panel_pictures, :id => @other_author.id
+ response.should render_template("panel_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
+ PanelPicture.should_receive(:list_json_opt).exactly(1)
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("link").should be_true
+ json.first.has_key?("x").should be_true
+ json.first.has_key?("y").should be_true
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panel_pictures, :id => @other_author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ context 'ユーザだが作家登録していないとき' do
+ before do
+ @author.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ end
+
+ describe '対象作家の絵地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @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
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
+ sign_in @user
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :ground_pictures, :id => @other_author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :ground_pictures, :id => @other_author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :ground_pictures, :id => @other_author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :ground_pictures, :id => @other_author.id
+ assigns(:page_size).should eq Author.default_ground_picture_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :ground_pictures, :id => @other_author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.ground_picture_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :ground_pictures, :id => @other_author.id, :page_size => 0
+ assigns(:page_size).should eq Author.default_ground_picture_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ it '作家モデルに単体取得を問い合わせている' do
+ Author.should_receive(:show).exactly(1)
+ get :ground_pictures, :id => @other_author.id
+ end
+ it '絵地モデルに他作家の絵地一覧を問い合わせている' do
+ GroundPicture.should_receive(:himlist).exactly(1)
+ get :ground_pictures, :id => @other_author.id
+ end
+ it '@ground_picturesにリストを取得している' do
+ get :ground_pictures, :id => @other_author.id
+ assigns(:ground_pictures).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'ground_picturesテンプレートを描画する' do
+ get :ground_pictures, :id => @other_author.id
+ response.should render_template("ground_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it '絵地モデルにjson一覧出力オプションを問い合わせている' do
+ GroundPicture.should_receive(:list_json_opt).exactly(1)
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("panel_id").should be_true
+ json.first.has_key?("picture_id").should be_true
+ json.first.has_key?("z").should be_true
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :ground_pictures, :id => @other_author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :ground_pictures, :id => @other_author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :ground_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ context 'ユーザだが作家登録していないとき' do
+ before do
+ @author.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :ground_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ end
+
+ describe '対象作家の選択色地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @color = FactoryGirl.create :color
+ @gc = FactoryGirl.create :ground_color, :color_id => @color.id
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
+ sign_in @user
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :ground_colors, :id => @other_author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :ground_colors, :id => @other_author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :ground_colors, :id => @other_author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :ground_colors, :id => @other_author.id
+ assigns(:page_size).should eq Author.default_ground_color_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :ground_colors, :id => @other_author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.ground_color_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :ground_colors, :id => @other_author.id, :page_size => 0
+ assigns(:page_size).should eq Author.ground_color_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_colors, :id => @other_author.id
+ response.should be_success
+ end
+ it '作家モデルに単体取得を問い合わせている' do
+ Author.should_receive(:show).exactly(1)
+ get :ground_colors, :id => @other_author.id
+ end
+ it '選択色地モデルに他作家の選択色地一覧を問い合わせている' do
+ GroundColor.should_receive(:himlist).exactly(1)
+ get :ground_colors, :id => @other_author.id
+ end
+ it '@ground_colorsにリストを取得している' do
+ get :ground_colors, :id => @other_author.id
+ assigns(:ground_colors).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'ground_colorsテンプレートを描画する' do
+ get :ground_colors, :id => @other_author.id
+ response.should render_template("ground_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it '選択色地モデルにjson一覧出力オプションを問い合わせている' do
+ GroundColor.should_receive(:list_json_opt).exactly(1)
+ get :ground_colors, :id => @other_author.id, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは選択色地っぽいものであって欲しい' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("panel_id").should be_true
+ json.first.has_key?("color_id").should be_true
+ json.first.has_key?("z").should be_true
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :ground_colors, :id => @other_author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :ground_colors, :id => @other_author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :ground_colors, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ context 'ユーザだが作家登録していないとき' do
+ before do
+ @author.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :ground_colors, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ end
+
+ describe '対象作家の指定色地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ PanelColor.stub(:himlist).and_return([@pc, @pc, @pc])
+ sign_in @user
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :panel_colors, :id => @other_author.id, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :panel_colors, :id => @other_author.id
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :panel_colors, :id => @other_author.id, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :panel_colors, :id => @other_author.id
+ assigns(:page_size).should eq Author.default_panel_color_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :panel_colors, :id => @other_author.id, :page_size => 1500
+ assigns(:page_size).should eq Author.panel_color_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :panel_colors, :id => @other_author.id, :page_size => 0
+ assigns(:page_size).should eq Author.panel_color_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_colors, :id => @other_author.id
+ response.should be_success
+ end
+ it '作家モデルに単体取得を問い合わせている' do
+ Author.should_receive(:show).exactly(1)
+ get :panel_colors, :id => @other_author.id
+ end
+ it '指定色地モデルに他作家の指定色地一覧を問い合わせている' do
+ PanelColor.should_receive(:himlist).exactly(1)
+ get :panel_colors, :id => @other_author.id
+ end
+ it '@panel_colorsにリストを取得している' do
+ get :panel_colors, :id => @other_author.id
+ assigns(:panel_colors).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'panel_colorsテンプレートを描画する' do
+ get :panel_colors, :id => @other_author.id
+ response.should render_template("panel_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it '指定色地モデルにjson一覧出力オプションを問い合わせている' do
+ PanelColor.should_receive(:list_json_opt).exactly(1)
+ get :panel_colors, :id => @other_author.id, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは指定色地っぽいものであって欲しい' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("panel_id").should be_true
+ json.first.has_key?("code").should be_true
+ json.first.has_key?("z").should be_true
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panel_colors, :id => @other_author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panel_colors, :id => @other_author.id
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :panel_colors, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ context 'ユーザだが作家登録していないとき' do
+ before do
+ @author.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :panel_colors, :id => @other_author.id
+ response.should be_success
+ end
+ end
+ end
+
describe '作家数取得に於いて' do
before do
Author.should_receive(:visible_count).and_return(3)
end
end
+ describe '対象作家のコマ絵一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @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
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
+ PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'panel_picturesテンプレートを描画する' do
+ get :panel_pictures, :id => @other_author.id
+ response.should render_template("panel_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :panel_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'panel_picturesテンプレートを描画する' do
+ get :panel_pictures, :id => @other_author.id
+ response.should render_template("panel_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '対象作家の絵地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @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
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_pictures, :id => @other_author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ground_picturesテンプレートを描画する' do
+ get :ground_pictures, :id => @other_author.id
+ response.should render_template("ground_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ground_picturesテンプレートを描画する' do
+ get :ground_pictures, :id => @other_author.id
+ response.should render_template("ground_pictures")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_pictures, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '対象作家の選択色地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @color = FactoryGirl.create :color
+ @gc = FactoryGirl.create :ground_color, :color_id => @color.id
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_colors, :id => @other_author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ground_colorsテンプレートを描画する' do
+ get :ground_colors, :id => @other_author.id
+ response.should render_template("ground_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ground_colorsテンプレートを描画する' do
+ get :ground_colors, :id => @other_author.id
+ response.should render_template("ground_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '対象作家の指定色地一覧表示に於いて' do
+ before do
+ @other_user = FactoryGirl.create( :user_yas)
+ @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+ @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ PanelColor.stub(:himlist).and_return([@pc, @pc, @pc])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_colors, :id => @other_author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'panel_colorsテンプレートを描画する' do
+ get :panel_colors, :id => @other_author.id
+ response.should render_template("panel_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context 'ユーザ権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'panel_colorsテンプレートを描画する' do
+ get :panel_colors, :id => @other_author.id
+ response.should render_template("panel_colors")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_colors, :id => @other_author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
describe '作家数取得に於いて' do
before do
Author.should_receive(:visible_count).and_return(3)
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = GroundColor.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = GroundColor.list_opt[:include]
- r.should have(2).items
- end
- it 'コマを含んでいる' do
- r = GroundColor.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = GroundColor.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- it '色を含んでいる' do
- r = GroundColor.list_opt[:include]
- r.has_key?(:color).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- before do
- @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
- @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
- @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
- @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
- end
- it 'コマを含んでいる' do
- r = GroundColor.list.to_json GroundColor.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('panel').should be_true
- end
- it 'コマは作家を含んでいる' do
- r = GroundColor.list.to_json GroundColor.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['panel']
- s.has_key?('author').should be_true
- end
- it '色を含んでいる' do
- r = GroundColor.list.to_json GroundColor.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('color').should be_true
- end
- end
-
describe '自分のコマで使った選択色地一覧取得に於いて' do
before do
@gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
end
end
+ describe '他作家の選択色地一覧取得に於いて' do
+ before do
+ @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_gc = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id
+ end
+ it 'リストを返す' do
+ r = GroundColor.himlist @other_author
+ r.should eq [@other_gc]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_gc = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 100
+ r = GroundColor.himlist @other_author
+ r.should eq [new_gc, @other_gc]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_gc = FactoryGirl.create :ground_color, :panel_id => hidden_panel.id, :color_id => @color.id
+ r = GroundColor.himlist @other_author
+ r.should eq [@other_gc]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_gc2 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 100
+ @other_gc3 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 200
+ @other_gc4 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 300
+ @other_gc5 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = GroundColor.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = GroundColor.himlist @other_author, 1, 2
+ pl.should eq [@other_gc5, @other_gc4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = GroundColor.himlist @other_author, 2, 2
+ pl.should eq [@other_gc3, @other_gc2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = GroundColor.himlist @other_author, 3, 2
+ pl.should eq [@other_gc]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_gc2 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 100
+ @other_gc3 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 200
+ @other_gc4 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 300
+ @other_gc5 = FactoryGirl.create :ground_color, :panel_id => @other_panel.id, :color_id => @color.id, :updated_at => Time.now + 400
+ Author.stub(:default_ground_color_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = GroundColor.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = GroundColor.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '2つの項目を含んでいる' do
+ r = GroundColor.list_opt[:include]
+ r.should have(2).items
+ end
+ it 'コマを含んでいる' do
+ r = GroundColor.list_opt[:include]
+ r.has_key?(:panel).should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = GroundColor.list_opt[:include]
+ r[:panel].has_key?(:author).should be_true
+ end
+ it '色を含んでいる' do
+ r = GroundColor.list_opt[:include]
+ r.has_key?(:color).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ before do
+ @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
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+ @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
+ end
+ it 'コマを含んでいる' do
+ r = GroundColor.list.to_json GroundColor.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('panel').should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = GroundColor.list.to_json GroundColor.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['panel']
+ s.has_key?('author').should be_true
+ end
+ it '色を含んでいる' do
+ r = GroundColor.list.to_json GroundColor.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('color').should be_true
+ end
+ end
+
describe '単体取得に於いて' do
before do
@gc = FactoryGirl.create :ground_color, :panel_id => @panel.id, :color_id => @color.id
end
end
end
+
+ describe '自分のコマで使った絵地一覧取得に於いて' do
+ before do
+ @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ end
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ GroundPicture.stub(:list_opt).with(any_args).and_return({:include => :panel})
+ GroundPicture.should_receive(:list_opt).with(any_args).exactly(1)
+ r = GroundPicture.mylist @author
+ end
+ end
+ it 'リストを返す' do
+ pl = GroundPicture.mylist @author
+ pl.should eq [@gp]
+ end
+ it '時系列で並んでいる' do
+ npl = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :z => 2, :updated_at => Time.now + 100
+ pl = GroundPicture.mylist @author
+ pl.should eq [npl, @gp]
+ end
+ it '他人のコマの絵地は公開でも含まない' do
+ hpl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ npl = FactoryGirl.create :ground_picture, :panel_id => hpl.id, :picture_id => @p.id
+ pl = GroundPicture.mylist @author
+ pl.should eq [@gp]
+ end
+ it '自分のコマの絵地は非公開でも含んでいる' do
+ hpl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
+ npl = FactoryGirl.create :ground_picture, :panel_id => hpl.id, :picture_id => @p.id, :z => 2, :updated_at => Time.now + 100
+ pl = GroundPicture.mylist @author
+ pl.should eq [npl, @gp]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
+ @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
+ @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
+ @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ c = GroundPicture.mylist @author, 1, 2
+ c.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ c = GroundPicture.mylist(@author, 1, 2)
+ c.should eq [@gp5, @gp4]
+ end
+ it 'page=2なら中間2件を返す' do
+ c = GroundPicture.mylist(@author, 2, 2)
+ c.should eq [@gp3, @gp2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ c = GroundPicture.mylist(@author, 3, 2)
+ c.should eq [@gp]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
+ @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
+ @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
+ @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
+ Author.stub(:default_ground_picture_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = GroundPicture.mylist @author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
+ describe '他作家の絵地一覧取得に於いて' do
+ before do
+ @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_gp = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id
+ end
+ it 'リストを返す' do
+ r = GroundPicture.himlist @other_author
+ r.should eq [@other_gp]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_gp = FactoryGirl.create :ground_picture, :panel_id => new_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ r = GroundPicture.himlist @other_author
+ r.should eq [new_gp, @other_gp]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_gp = FactoryGirl.create :ground_picture, :panel_id => hidden_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ r = GroundPicture.himlist @other_author
+ r.should eq [@other_gp]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_gp2 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ @other_gp3 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 200
+ @other_gp4 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 300
+ @other_gp5 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = GroundPicture.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = GroundPicture.himlist @other_author, 1, 2
+ pl.should eq [@other_gp5, @other_gp4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = GroundPicture.himlist @other_author, 2, 2
+ pl.should eq [@other_gp3, @other_gp2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = GroundPicture.himlist @other_author, 3, 2
+ pl.should eq [@other_gp]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_gp2 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 100
+ @other_gp3 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 200
+ @other_gp4 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 300
+ @other_gp5 = FactoryGirl.create :ground_picture, :panel_id => @other_panel.id, :picture_id => @p.id, :updated_at => Time.now + 400
+ Author.stub(:default_ground_picture_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = GroundPicture.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
describe '一覧取得オプションに於いて' do
it 'includeキーを含んでいる' do
r = GroundPicture.list_opt
end
end
- describe '自分のコマで使った絵地一覧取得に於いて' do
- before do
- @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
- end
- context 'つつがなく終わるとき' do
- it '一覧取得オプションを利用している' do
- GroundPicture.stub(:list_opt).with(any_args).and_return({:include => :panel})
- GroundPicture.should_receive(:list_opt).with(any_args).exactly(1)
- r = GroundPicture.mylist @author
- end
- end
- it 'リストを返す' do
- pl = GroundPicture.mylist @author
- pl.should eq [@gp]
- end
- it '時系列で並んでいる' do
- npl = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id, :z => 2, :updated_at => Time.now + 100
- pl = GroundPicture.mylist @author
- pl.should eq [npl, @gp]
- end
- it '他人のコマの絵地は公開でも含まない' do
- hpl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
- npl = FactoryGirl.create :ground_picture, :panel_id => hpl.id, :picture_id => @p.id
- pl = GroundPicture.mylist @author
- pl.should eq [@gp]
- end
- it '自分のコマの絵地は非公開でも含んでいる' do
- hpl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
- npl = FactoryGirl.create :ground_picture, :panel_id => hpl.id, :picture_id => @p.id, :z => 2, :updated_at => Time.now + 100
- pl = GroundPicture.mylist @author
- pl.should eq [npl, @gp]
- end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
- @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
- @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
- @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
- end
- it '通常は2件を返す' do
- c = GroundPicture.mylist @author, 1, 2
- c.should have(2).items
- end
- it 'page=1なら末尾2件を返す' do
- #時系列で並んでいる
- c = GroundPicture.mylist(@author, 1, 2)
- c.should eq [@gp5, @gp4]
- end
- it 'page=2なら中間2件を返す' do
- c = GroundPicture.mylist(@author, 2, 2)
- c.should eq [@gp3, @gp2]
- end
- it 'page=3なら先頭1件を返す' do
- c = GroundPicture.mylist(@author, 3, 2)
- c.should eq [@gp]
- end
- end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
- before do
- @gp2 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 1, :picture_id => @p.id, :updated_at => Time.now + 100
- @gp3 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 2, :picture_id => @p.id, :updated_at => Time.now + 200
- @gp4 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 3, :picture_id => @p.id, :updated_at => Time.now + 300
- @gp5 = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :z => 4, :picture_id => @p.id, :updated_at => Time.now + 400
- Author.stub(:default_ground_picture_page_size).and_return(2)
- end
- it '通常は全件(5件)を返す' do
- r = GroundPicture.mylist @author, 5, 0
- r.should have(5).items
- end
- end
- end
-
describe '単体取得に於いて' do
before do
@gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = PanelColor.list_opt
- r.has_key?(:include).should be_true
- end
- it '1つの項目を含んでいる' do
- r = PanelColor.list_opt[:include]
- r.should have(1).items
- end
- it 'コマを含んでいる' do
- r = PanelColor.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelColor.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- before do
- @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
- @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
- @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
- @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
- end
- it 'コマを含んでいる' do
- r = PanelColor.list.to_json PanelColor.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('panel').should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelColor.list.to_json PanelColor.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['panel']
- s.has_key?('author').should be_true
- end
- end
describe '自分のコマで使った指定色地一覧取得に於いて' do
before do
end
end
+ describe '他作家の指定色地一覧取得に於いて' do
+ before do
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_pc = FactoryGirl.create :panel_color, :panel_id => @other_panel.id
+ end
+ it 'リストを返す' do
+ r = PanelColor.himlist @other_author
+ r.should eq [@other_pc]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_pc = FactoryGirl.create :panel_color, :panel_id => new_panel.id, :updated_at => Time.now + 100
+ r = PanelColor.himlist @other_author
+ r.should eq [new_pc, @other_pc]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_pc = FactoryGirl.create :panel_color, :panel_id => hidden_panel.id
+ r = PanelColor.himlist @other_author
+ r.should eq [@other_pc]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_pc2 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 100
+ @other_pc3 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 200
+ @other_pc4 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 300
+ @other_pc5 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = PanelColor.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = PanelColor.himlist @other_author, 1, 2
+ pl.should eq [@other_pc5, @other_pc4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = PanelColor.himlist @other_author, 2, 2
+ pl.should eq [@other_pc3, @other_pc2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = PanelColor.himlist @other_author, 3, 2
+ pl.should eq [@other_pc]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_pc2 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 100
+ @other_pc3 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 200
+ @other_pc4 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 300
+ @other_pc5 = FactoryGirl.create :panel_color, :panel_id => @other_panel.id, :updated_at => Time.now + 400
+ Author.stub(:default_panel_color_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = PanelColor.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = PanelColor.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '1つの項目を含んでいる' do
+ r = PanelColor.list_opt[:include]
+ r.should have(1).items
+ end
+ it 'コマを含んでいる' do
+ r = PanelColor.list_opt[:include]
+ r.has_key?(:panel).should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelColor.list_opt[:include]
+ r[:panel].has_key?(:author).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ before do
+ @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
+ @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+ end
+ it 'コマを含んでいる' do
+ r = PanelColor.list.to_json PanelColor.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('panel').should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelColor.list.to_json PanelColor.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['panel']
+ s.has_key?('author').should be_true
+ end
+ end
+
describe '単体取得に於いて' do
before do
@pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = PanelPicture.list_opt
- r.has_key?(:include).should be_true
- end
- it '2つの項目を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.should have(2).items
- end
- it 'コマを含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- it '実素材を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r.has_key?(:picture).should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:picture].has_key?(:artist).should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = PanelPicture.list_opt[:include]
- r[:picture].has_key?(:license).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- before do
- @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
- @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
- :width => @p.width, :height => @p.height
- end
- it 'コマを含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('panel').should be_true
- end
- it 'コマは作家を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['panel']
- s.has_key?('author').should be_true
- end
- it '実素材を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- i.has_key?('picture').should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['picture']
- s.has_key?('artist').should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = PanelPicture.list.to_json PanelPicture.list_json_opt
- j = JSON.parse r
- i = j.first
- s = i['picture']
- s.has_key?('license').should be_true
- end
- end
describe '自分のコマ絵一覧取得に於いて' do
before do
end
end
+ describe '他作家のコマ絵一覧取得に於いて' do
+ before do
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_pp = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ end
+ it 'リストを返す' do
+ r = PanelPicture.himlist @other_author
+ r.should eq [@other_pp]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_pc = FactoryGirl.create :panel_picture, :panel_id => new_panel.id, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ r = PanelPicture.himlist @other_author
+ r.should eq [new_pc, @other_pp]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_pp = FactoryGirl.create :panel_picture, :panel_id => hidden_panel.id, :picture_id => @p.id, :width => @p.width, :height => @p.height
+ r = PanelPicture.himlist @other_author
+ r.should eq [@other_pp]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_pp2 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 1, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ @other_pp3 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 2, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
+ @other_pp4 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 3, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
+ @other_pp5 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 4, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
+ end
+ it '通常は2件を返す' do
+ pl = PanelPicture.himlist @other_author, 1, 2
+ pl.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ pl = PanelPicture.himlist @other_author, 1, 2
+ pl.should eq [@other_pp5, @other_pp4]
+ end
+ it 'page=2なら中間2件を返す' do
+ pl = PanelPicture.himlist @other_author, 2, 2
+ pl.should eq [@other_pp3, @other_pp2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ pl = PanelPicture.himlist @other_author, 3, 2
+ pl.should eq [@other_pp]
+ end
+ end
+ context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ before do
+ @other_pp2 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 1, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 100
+ @other_pp3 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 2, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 200
+ @other_pp4 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 3, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 300
+ @other_pp5 = FactoryGirl.create :panel_picture, :panel_id => @other_panel.id, :t => 4, :picture_id => @p.id, :width => @p.width, :height => @p.height, :updated_at => Time.now + 400
+ Author.stub(:default_panel_picture_page_size).and_return(2)
+ end
+ it '通常は全件(5件)を返す' do
+ r = PanelPicture.himlist @other_author, 5, 0
+ r.should have(5).items
+ end
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
+ it 'includeキーを含んでいる' do
+ r = PanelPicture.list_opt
+ r.has_key?(:include).should be_true
+ end
+ it '2つの項目を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.should have(2).items
+ end
+ it 'コマを含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.has_key?(:panel).should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:panel].has_key?(:author).should be_true
+ end
+ it '実素材を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r.has_key?(:picture).should be_true
+ end
+ it '実素材は絵師を含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:picture].has_key?(:artist).should be_true
+ end
+ it '実素材はライセンスを含んでいる' do
+ r = PanelPicture.list_opt[:include]
+ r[:picture].has_key?(:license).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
+ before do
+ @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
+ @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ end
+ it 'コマを含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('panel').should be_true
+ end
+ it 'コマは作家を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['panel']
+ s.has_key?('author').should be_true
+ end
+ it '実素材を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ i.has_key?('picture').should be_true
+ end
+ it '実素材は絵師を含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['picture']
+ s.has_key?('artist').should be_true
+ end
+ it '実素材はライセンスを含んでいる' do
+ r = PanelPicture.list.to_json PanelPicture.list_json_opt
+ j = JSON.parse r
+ i = j.first
+ s = i['picture']
+ s.has_key?('license').should be_true
+ end
+ end
+
describe '単体取得に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,