OSDN Git Service

t#31223:add them contents list for author and artist
authoryasushiito <yas@pen-chan.jp>
Sat, 27 Apr 2013 01:53:49 +0000 (10:53 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 27 Apr 2013 01:53:49 +0000 (10:53 +0900)
16 files changed:
app/controllers/artists_controller.rb
app/controllers/authors_controller.rb
app/controllers/home_controller.rb
app/models/author.rb
app/models/resource_picture.rb
app/views/artists/resource_pictures.html.erb [new file with mode: 0644]
app/views/artists/show.html.erb
app/views/authors/_list_item.html.erb [new file with mode: 0644]
app/views/authors/comics.html.erb [new file with mode: 0644]
app/views/authors/panels.html.erb [new file with mode: 0644]
app/views/authors/show.html.erb
config/locales/pettanr.ja.yml
config/routes.rb
spec/controllers/artists_controller_spec.rb
spec/controllers/authors_controller_spec.rb
spec/controllers/home_controller_spec.rb

index 032a98a..51543bb 100644 (file)
@@ -4,7 +4,7 @@ class ArtistsController < ApplicationController
     before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   else
-    before_filter :authenticate_resource_reader, :only => [:index, :show]
+    before_filter :authenticate_resource_reader, :only => [:index, :show, :resource_pictures]
     before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy]
     before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy]
   end
@@ -34,6 +34,19 @@ class ArtistsController < ApplicationController
     end
   end
 
+  def resource_pictures
+    @ar = Artist.show(params[:id], [@user, @admin, @demand_user])
+    
+    @page = Author.page params[:page]
+    @page_size = Author.resource_picture_page_size params[:page_size]
+    @resource_pictures = ResourcePicture.mylist(@ar, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @resource_pictures.to_json(ResourcePicture.list_json_opt) }
+    end
+  end
+  
   def count
     @ar = {:count => Artist.visible_count}
     respond_to do |format|
index 5e8632e..531f46d 100644 (file)
@@ -4,7 +4,7 @@ class AuthorsController < ApplicationController
     before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
     before_filter :authenticate_author, :only => [:edit, :update]
   else
-    before_filter :authenticate_reader, :only => [:index, :show]
+    before_filter :authenticate_reader, :only => [:index, :show, :comics, :panels]
     before_filter :authenticate_user, :only => [:new, :create, :edit, :update]
     before_filter :authenticate_author, :only => [:edit, :update]
   end
@@ -30,6 +30,32 @@ class AuthorsController < ApplicationController
     end
   end
 
+  def comics
+    @au = Author.show(params[:id], [@user, @admin])
+
+    @page = Author.page params[:page]
+    @page_size = Author.comic_page_size params[:page_size]
+    @comics = Comic.mylist(@au, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render json: @comics.to_json(Comic.list_json_opt) }
+    end
+  end
+  
+  def panels
+    @au = Author.show(params[:id], [@user, @admin])
+
+    @page = Author.page params[:page]
+    @page_size = Author.panel_page_size params[:page_size]
+    @panels = Panel.mylist(@au, @page, @page_size)
+
+    respond_to do |format|
+      format.html # index.html.erb
+      format.json { render text: Panel.list_as_json_text(@panels) }
+    end
+  end
+  
   def count
     @au = {:count => Author.visible_count}
     respond_to do |format|
index 92a2b13..6d4babc 100644 (file)
@@ -86,7 +86,7 @@ class HomeController < ApplicationController
   
   def panel_color
     @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
+    @page_size = Author.panel_colorl_page_size params[:page_size]
     @panel_colors = PanelColor.mylist(@author, @page, @page_size)
 
     respond_to do |format|
@@ -97,7 +97,7 @@ class HomeController < ApplicationController
   
   def ground_picture
     @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
+    @page_size = Author.ground_picture_page_size params[:page_size]
     @ground_pictures = GroundPicture.mylist(@author, @page, @page_size)
 
     respond_to do |format|
@@ -108,7 +108,7 @@ class HomeController < ApplicationController
   
   def ground_color
     @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
+    @page_size = Author.ground_color_page_size params[:page_size]
     @ground_colors = GroundColor.mylist(@author, @page, @page_size)
 
     respond_to do |format|
@@ -119,8 +119,8 @@ class HomeController < ApplicationController
   
   def resource_picture
     @page = Author.page params[:page]
-    @page_size = Author.panel_page_size params[:page_size]
-    @resource_pictures = ResourcePicture.mylist(@author, @page, @page_size)
+    @page_size = Author.resource_picture_page_size params[:page_size]
+    @resource_pictures = ResourcePicture.mylist(@artist, @page, @page_size)
 
     respond_to do |format|
       format.html # index.html.erb
index b234a79..3b56286 100644 (file)
@@ -216,7 +216,7 @@ class Author < ActiveRecord::Base
   end
   
   def self.default_resource_picture_page_size
-    25
+    125
   end
   
   def self.resource_picture_max_page_size
index 99cd82c..dec37a0 100644 (file)
@@ -88,7 +88,7 @@ class ResourcePicture < ActiveRecord::Base
   end
   
   def self.default_page_size
-    25
+    125
   end
   
   def self.max_page_size
diff --git a/app/views/artists/resource_pictures.html.erb b/app/views/artists/resource_pictures.html.erb
new file mode 100644 (file)
index 0000000..ead33de
--- /dev/null
@@ -0,0 +1,38 @@
+<h1><%= t '.title' -%></h1>
+
+<table>
+  <tr>
+    <th></th>
+    <th></th>
+    <th><%= t_m 'ResourcePicture.artist_id' -%></th>
+    <th><%= t_m 'ResourcePicture.ext' -%></th>
+    <th><%= t_m 'ResourcePicture.width' -%></th>
+    <th><%= t_m 'ResourcePicture.height' -%></th>
+    <th><%= t_m 'ResourcePicture.filesize' -%></th>
+  </tr>
+<% @resource_pictures.each do |resource_picture| %>
+  <tr>
+    <td>
+      <%= link_to tag(:img, resource_picture.tmb_opt_img_tag), resource_picture_path(resource_picture) %>
+    </td>
+    <td>
+      <%= render resource_picture.credit_template, :picture => resource_picture %>
+    </td>
+    <td>
+      <%= link_to(h(truncate(resource_picture.artist.name, :length => 8)), artist_path(resource_picture.artist)) %>
+    </td>
+    <td>
+      <%= h resource_picture.ext %>
+    </td>
+    <td>
+      <%= resource_picture.width %>px
+    </td>
+    <td>
+      <%= resource_picture.height %>px
+    </td>
+    <td>
+      <%= resource_picture.filesize %>bytes
+    </td>
+  </tr>
+<% end %>
+</table>
index 6c58138..96cc8f2 100644 (file)
   <%= l @ar.updated_at %>
 </p>
 
+<p>
+  <%= link_to t('artists.show.to_resource_pictures'), resource_pictures_artist_path(@ar) %>
+</p>
+
 <% if @ar.own?(@artist) %>
   <%= link_to t('link.edit'), edit_artist_path(@ar) %>
 <% end %>
diff --git a/app/views/authors/_list_item.html.erb b/app/views/authors/_list_item.html.erb
new file mode 100644 (file)
index 0000000..1bf947a
--- /dev/null
@@ -0,0 +1,20 @@
+<tr>
+  <td>
+    <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
+    <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
+    (<%= comic.stories.size -%>)
+  </td>
+  <td>
+    <%= distance_of_time_in_words_to_now comic.updated_at %>
+  </td>
+  <td>
+    <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
+    <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
+  </td>
+  <td>
+    <% if comic.own? author %>
+      <%= link_to t('link.edit'), edit_comic_path(comic) %>
+      <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %>
+    <% end %>
+  </td>
+</tr>
diff --git a/app/views/authors/comics.html.erb b/app/views/authors/comics.html.erb
new file mode 100644 (file)
index 0000000..b132d0b
--- /dev/null
@@ -0,0 +1,27 @@
+<h1><%= t '.title' -%></h1>
+
+<table>
+  <% @comics.each do |comic| %>
+    <tr>
+      <td>
+        <%= link_to comic_icon(:object => comic, :size => 25), comic_path(comic) %>
+        <%= link_to h(truncate(comic.title, :length => 40)), :controller => 'stories', :action => :comic, :id => comic.id %>
+        (<%= comic.stories.size -%>)
+      </td>
+      <td>
+        <%= distance_of_time_in_words_to_now comic.updated_at %>
+      </td>
+      <td>
+        <%= link_to author_icon(:object => comic.author, :size => 25), comic_path(comic.author) %>
+        <%= link_to h(truncate(comic.author.name, :length => 12)), author_path(comic.author) %>
+      </td>
+      <td>
+        <% if comic.own? @author %>
+          <%= link_to t('link.edit'), edit_comic_path(comic) %>
+          <%= link_to t('link.destroy'), comic_path(comic), :method => :delete %>
+        <% end %>
+      </td>
+    </tr>
+  <% end %>
+</table>
+<%= link_to t('comics.new.title'), new_comic_path %>
diff --git a/app/views/authors/panels.html.erb b/app/views/authors/panels.html.erb
new file mode 100644 (file)
index 0000000..34ee4da
--- /dev/null
@@ -0,0 +1,5 @@
+<h1><%= t '.title' -%></h1>
+<% @panels.each do |panel| %>
+  <%= render 'panels/standard', :panel => panel, :author => @author %>
+<% end %>
+<%= link_to t('panels.new.title'), new_panel_path %>
index a203fec..97f54d2 100644 (file)
   <%= l @au.updated_at %>
 </p>
 
+<p>
+  <%= link_to t('authors.show.to_comics'), comics_author_path(@au) %>
+</p>
+
+<p>
+  <%= link_to t('authors.show.to_panels'), panels_author_path(@au) %>
+</p>
+
 <% if @au.own?(@author) %>
   <%= link_to t('link.edit'), edit_author_path(@au) %>
 <% end %>
index 39a025a..ee9fc45 100644 (file)
@@ -668,6 +668,12 @@ ja:
       title: 作家一覧
     show:
       title: 作家詳細
+      to_comics: 最近更新したコミック
+      to_panels: 最近更新したコマ
+    comics:
+      title: 最近更新したコミック
+    panels:
+      title: 最近更新したコマ
     new:
       title: 作家登録
       announce: 作家登録してください
@@ -688,6 +694,9 @@ ja:
       title: 絵師一覧
     show:
       title: 絵師詳細
+      to_resource_pictures: 最近更新した素材
+    resource_pictures:
+      title: 最近更新した素材
     new:
       title: 絵師登録
     edit:
index 003ea56..3c48f08 100644 (file)
@@ -23,6 +23,8 @@ Pettanr::Application.routes.draw do
       put :update
       delete :destroy
       get :browse
+      get :comics
+      get :panels
     end
   end
   resources :artists do
@@ -40,6 +42,7 @@ Pettanr::Application.routes.draw do
       put :update
       delete :destroy
       get :browse
+      get :resource_pictures
     end
   end
   resources :speech_balloon_templates do
index d1f7a3a..f36d754 100644 (file)
@@ -256,6 +256,134 @@ if MagicNumber['run_mode'] == 1
 =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 => @other_artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @other_artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :resource_pictures, :id => @other_artist.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :resource_pictures, :id => @other_artist.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :resource_pictures, :id => @other_artist.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :resource_pictures, :id => @other_artist.id
+        assigns(:page_size).should eq Author.default_resource_picture_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :resource_pictures, :id => @other_artist.id, :page_size => 1500
+        assigns(:page_size).should eq Author.resource_picture_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :resource_pictures, :id => @other_artist.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_resource_picture_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :resource_pictures, :id => @other_artist.id
+        response.should be_success 
+      end
+      it '絵師モデルに単体取得を問い合わせている' do
+        Artist.should_receive(:show).exactly(1)
+        get :resource_pictures, :id => @other_artist.id
+      end
+      it '素材モデルに一覧を問い合わせている' do
+        ResourcePicture.should_receive(:mylist).exactly(1)
+        get :resource_pictures, :id => @other_artist.id
+      end
+      it '@resource_picturesにリストを取得している' do
+        get :resource_pictures, :id => @other_artist.id
+        assigns(:resource_pictures).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it 'resource_pictureテンプレートを描画する' do
+          get :resource_pictures, :id => @other_artist.id
+          response.should render_template("resource_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '素材モデルにコマリストのjson出力を問い合わせている' do
+          ResourcePicture.should_receive(:list_json_opt).exactly(1)
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいは素材っぽいものであって欲しい' do
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("original_picture_id").should be_true
+          json.first.has_key?("license_id").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :resource_pictures, :id => @other_artist.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :resource_pictures, :id => @other_artist.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :resource_pictures, :id => @other_artist.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 :resource_pictures, :id => @other_artist.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @artist.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :resource_pictures, :id => @other_artist.id
+        response.should be_success 
+      end
+    end
+  end
+  
   describe '絵師数取得に於いて' do
     before do
       Artist.should_receive(:visible_count).and_return(3)
@@ -857,6 +985,58 @@ else
     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 => @other_artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @other_artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @other_artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :resource_pictures, :id => @other_artist.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'resource_pictureテンプレートを描画する' do
+          get :resource_pictures, :id => @other_artist.id
+          response.should render_template("resource_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :resource_pictures, :id => @other_artist.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 :resource_pictures, :id => @other_artist.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'resource_pictureテンプレートを描画する' do
+          get :resource_pictures, :id => @other_artist.id
+          response.should render_template("resource_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :resource_pictures, :id => @other_artist.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
   describe '絵師数取得に於いて' do
     before do
       Artist.should_receive(:visible_count).and_return(3)
index b0e6817..2ef2701 100644 (file)
@@ -238,6 +238,257 @@ if MagicNumber['run_mode'] == 1
 =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
+      @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
+      Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :comics, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :comics, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :comics, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :comics, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_comic_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :comics, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.comic_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :comics, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_comic_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :comics, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :comics, :id => @other_author.id
+      end
+      it 'コミックモデルに一覧を問い合わせている' do
+        Comic.should_receive(:mylist).exactly(1)
+        get :comics, :id => @other_author.id
+      end
+      it '@comicsにリストを取得している' do
+        get :comics, :id => @other_author.id
+        assigns(:comics).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :comics, :id => @other_author.id
+          response.should render_template("comic")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :comics, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
+          Comic.should_receive(:list_json_opt).exactly(1)
+          get :comics, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :comics, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
+          get :comics, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("title").should be_true
+          json.first.has_key?("visible").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :comics, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :comics, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :comics, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :comics, :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 :comics, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :comics, :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 => @other_author.id
+      Panel.stub(:mylist).and_return([@panel, @panel, @panel])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :panels, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :panels, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :panels, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :panels, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_panel_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :panels, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.panel_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :panels, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_panel_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :panels, :id => @other_author.id
+      end
+      it 'コマモデルに一覧を問い合わせている' do
+        Panel.should_receive(:mylist).exactly(1)
+        get :panels, :id => @other_author.id
+      end
+      it '@panelsにリストを取得している' do
+        get :panels, :id => @other_author.id
+        assigns(:panels).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'コマモデルにコマリストのjson出力を問い合わせている' do
+          Panel.should_receive(:list_as_json_text).exactly(1)
+          get :panels, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはコマっぽいものであって欲しい' do
+          get :panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          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 :panels, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :panels, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :panels, :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 :panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
   describe '作家数取得に於いて' do
     before do
       Author.should_receive(:visible_count).and_return(3)
@@ -828,6 +1079,106 @@ else
     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
+      @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
+      Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :comics, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :comics, :id => @other_author.id
+          response.should render_template("comic")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :comics, :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 :comics, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :comics, :id => @other_author.id
+          response.should render_template("comic")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :comics, :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 => @other_author.id
+      Panel.stub(:mylist).and_return([@panel, @panel, @panel])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :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 :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'comicテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :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)
index feba48d..d3e0281 100644 (file)
@@ -650,15 +650,15 @@ if MagicNumber['run_mode'] == 1
       end
       it '省略されると@page_sizeにデフォルト値が入る' do
         get :resource_picture
-        assigns(:page_size).should eq Author.default_comic_page_size
+        assigns(:page_size).should eq Author.default_resource_picture_page_size
       end
       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
         get :resource_picture, :page_size => 1500
-        assigns(:page_size).should eq Author.comic_max_page_size
+        assigns(:page_size).should eq Author.resource_picture_max_page_size
       end
       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
         get :resource_picture, :page_size => 0
-        assigns(:page_size).should eq Author.default_comic_page_size
+        assigns(:page_size).should eq Author.default_resource_picture_page_size
       end
     end
     context 'つつがなく終わるとき' do