OSDN Git Service

fix: any
[pettanr/pettanr.git] / spec / controllers / stories_controller_spec.rb
index 5124482..3f7656a 100644 (file)
@@ -3,60 +3,1186 @@ require 'spec_helper'
 #ストーリー
 describe StoriesController do
   before do
-    Factory :admin
-    @license = Factory :license
-    @user = Factory :user_yas
-    @author = @user.author    #ユーザ作成時に連動して作成される
-    @comic = Factory :comic, :author_id => @user.author.id
-    @panel = Factory :panel, :author_id => @author.id
+    @admin = FactoryGirl.create :admin
+    @sp = FactoryGirl.create :system_picture
+    @lg = FactoryGirl.create :license_group
+    @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+    @user = FactoryGirl.create :user_yas
+    @author = FactoryGirl.create :author, :user_id => @user.id
+    @comic = FactoryGirl.create :comic, :author_id => @user.author.id
   end
   
+if MagicNumber['run_mode'] == 1
+  describe '一覧表示に於いて' do
+    before do
+      sign_in @user
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      Story.stub(:list).and_return([@story, @story, @story])
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :index, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :index
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :index, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :index
+        assigns(:page_size).should eq Story.default_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :index, :page_size => 1500
+        assigns(:page_size).should eq Story.max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :index, :page_size => 0
+        assigns(:page_size).should eq Story.default_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+      it 'ストーリーモデルに一覧を問い合わせている' do
+        Story.should_receive(:list).exactly(1)
+        get :index
+      end
+      it '@storiesにリストを取得している' do
+        get :index
+        assigns(:stories).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :index
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'indexテンプレートを描画する' do
+          get :index
+          response.should render_template("index")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :index, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
+          Story.should_receive(:list_json_opt).exactly(1)
+          get :index, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :index, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
+          get :index, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("title").should be_true
+          json.first.has_key?("comic_id").should be_true
+          json.first.has_key?("t").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :index
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :index
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :index, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :index, :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 :index
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '単体表示に於いて' do
+    before do
+      sign_in @user
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic)
+      Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic)
+    end
+    context 'つつがなく終わるとき' do
+      it 'ストーリーモデルに単体取得を問い合わせている' do
+        Story.should_receive(:show).with(@story.id.to_s, [@user, nil]).exactly(1)
+        get :show, :id => @story.id
+      end
+      it '@storyにアレを取得している' do
+        get :show, :id => @story.id
+        assigns(:story).should eq @story
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id
+          response.should be_success
+        end
+        it 'showテンプレートを描画する' do
+          get :show, :id => @story.id
+          response.should render_template("show")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id, :format => :json
+          response.should be_success
+        end
+        it 'jsonデータを返す' do
+          get :show, :id => @story.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'ストーリーモデルにjson単体出力オプションを問い合わせている' do
+          Story.should_receive(:show_json_opt).exactly(1)
+          get :show, :id => @story.id, :format => :json
+        end
+        it 'データがアレになっている' do
+          get :show, :id => @story.id, :format => :json
+          json = JSON.parse response.body
+          json.has_key?("title").should be_true
+          json.has_key?("comic_id").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :show, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :show, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :show, :id => @story.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :show, :id => @story.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 :show, :id => @story.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '閲覧に於いて' do
+    before do
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+      @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story)
+      Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story)
+      Story.stub(:count).and_return(10)
+      StorySheet.stub(:play_sheet).with(any_args).and_return(@sheet)
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :play, :id => @story.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :play, :id => @story.id
+        assigns(:page).should eq 1
+      end
+    end
+    context '事前チェックする' do
+      it 'ストーリーモデルに単体取得を問い合わせている' do
+        Story.should_receive(:show).with(@story.id.to_s, [@user, nil]).exactly(1)
+        get :play, :id => @story.id
+      end
+      it 'スト紙モデルにプレイリスト取得を問い合わせている' do
+        StorySheet.should_receive(:play_sheet).with(@story, @author, 1).exactly(1)
+        get :play, :id => @story.id
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it '@sheetに用紙を取得している' do
+        get :play, :id => @story.id
+        assigns(:sheet).should eq @sheet
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :play, :id => @story.id
+          response.should be_success 
+        end
+        it 'playテンプレートを描画する' do
+          get :play, :id => @story.id
+          response.should render_template("play")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :play, :id => @story.id, :format => :json
+          response.should be_success 
+        end
+        it 'jsonデータを返す' do
+          get :play, :id => @story.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '紙コマモデルに紙コマリストのjson出力を問い合わせている' do
+          SheetPanel.should_receive(:list_as_json_text).exactly(1)
+          get :play, :id => @story.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :play, :id => @story.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(1).items
+        end
+        it 'リストの先頭くらいは紙コマっぽいものであって欲しい' do
+          get :play, :id => @story.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("sheet_id").should be_true
+          json.first.has_key?("panel_id").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :play, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :play, :id => @story.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :play, :id => @story.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :play, :id => @story.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 :play, :id => @story.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :play, :id => @story.id
+        response.should be_success 
+      end
+    end
+  end
+
+  describe '新規作成フォーム表示に於いて' do
+    before do
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it '@storyに新規データを用意している' do
+        get :new
+        assigns(:story).should be_a_new(Story)
+      end
+      it 'モデルにデフォルト値補充を依頼している' do
+        Story.any_instance.should_receive(:supply_default).exactly(1)
+        get :new
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new
+          response.should be_success 
+        end
+        it 'newテンプレートを描画する' do
+          get :new
+          response.should render_template("new")
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new, :format => :js
+          response.should be_success 
+        end
+        it 'new.jsテンプレートを描画する' do
+          get :new, :format => :js
+          response.should render_template("new")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new, :format => :json
+          response.should be_success 
+        end
+        it 'jsonデータを返す' do
+          get :new, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'ストーリーモデルのjson単体出力オプションを問い合わせている' do
+          Story.should_receive(:show_json_opt).exactly(1)
+          get :new, :format => :json
+        end
+        it 'データがアレになっている' do
+          get :new, :format => :json
+          json = JSON.parse response.body
+          json.has_key?("title").should be_true
+          json.has_key?("comic_id").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :new
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :new, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :new, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :new
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          get :new
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+  end
+  
+  describe '新規作成に於いて' do
+    before do
+      @attr = FactoryGirl.attributes_for(:story, :t => 0, :comic_id => @comic.id)
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'デフォルト値補充を依頼する' do
+        Story.any_instance.should_receive(:supply_default).exactly(1)
+        post :create, :story => @attr
+      end
+      it 'POSTデータから、カラム値を復元している' do
+#        Story.any_instance.stub(:store).and_return(true)
+        post :create, :story => @attr
+        assigns(:story).comic_id.should eq @comic.id
+      end
+      it '上書き補充を依頼する' do
+        Story.any_instance.should_receive(:overwrite).exactly(1)
+        post :create, :story => @attr
+      end
+      it 'コミックモデルに編集取得を依頼している' do
+        Comic.should_receive(:edit).with(@comic.id, @author).exactly(1)
+        post :create, :story => @attr
+      end
+      it 'モデルに保存依頼する' do
+        Story.any_instance.should_receive(:store).exactly(1)
+        post :create, :story => @attr
+      end
+      it "@storyに作成されたストーリーを保持していて、それがDBにある" do
+        post :create, :story => @attr
+        assigns(:story).should be_a(Story)
+        assigns(:story).should be_persisted
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+#          Story.any_instance.stub(:store).and_return(true)
+          post :create, :story => @attr
+          response.status.should eq 302
+        end
+        it '作成されたストーリーの表示へページ位置を指定して遷移する' do
+#          Story.any_instance.stub(:store).and_return(true)
+          post :create, :story => @attr
+          response.should redirect_to(play_story_path(assigns(:story), :page => 1))
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+#          Story.any_instance.stub(:store).and_return(true)
+          post :create, :story => @attr, :format => :json
+          response.should be_success 
+        end
+        it '作成されたコマをjsonデータで返す' do
+          post :create, :story => @attr, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'ストーリーモデルのjson単体出力オプションを問い合わせている' do
+          Story.should_receive(:show_json_opt).exactly(1)
+          post :create, :story => @attr, :format => :json
+        end
+        it 'データがアレになっている' do
+          post :create, :story => @attr, :format => :json
+          json = JSON.parse response.body
+          json["t"].should eq 0
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :story => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          post :create, :story => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          post :create, :story => @attr, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          post :create, :story => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :story => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          post :create, :story => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :story => @attr
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          post :create, :story => @attr
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+    context '検証、保存に失敗した' do
+      before do
+        Story.any_instance.stub(:store).and_return(false)
+      end
+      it "未保存のコマを保持している" do
+        post :create, :story => @attr
+        assigns(:story).should be_a_new(Story)
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          post :create, :story => @attr
+          response.status.should eq 200
+        end
+        it '新規ページを描画する' do
+          post :create, :story => @attr
+          response.should render_template("new")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード422 unprocessable_entity を返す' do
+          post :create, :story => @attr, :format => :json
+          response.status.should eq 422
+        end
+        it '応答メッセージUnprocessable Entityを返す' do
+          post :create, :story => @attr, :format => :json
+          response.message.should match(/Unprocessable/)
+        end
+      end
+    end
+  end
+
+  describe '編集フォーム表示に於いて' do
+    before do
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      sign_in @user
+      Story.stub(:show).and_return(@story)
+    end
+    context 'つつがなく終わるとき' do
+      it 'ストーリーモデルに編集取得を問い合わせている' do
+        Story.should_receive(:edit).exactly(1)
+        get :edit, :id => @story.id
+      end
+      it '@storyにデータを用意している' do
+        get :edit, :id => @story.id
+        assigns(:story).should eq @story
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :edit, :id => @story.id
+          response.should be_success 
+        end
+        it 'editテンプレートを描画する' do
+          get :edit, :id => @story.id
+          response.should render_template("edit")
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :edit, :id => @story.id, :format => :js
+          response.should be_success 
+        end
+        it 'edit.jsテンプレートを描画する' do
+          get :edit, :id => @story.id, :format => :js
+          response.should render_template("edit")
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :edit, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :edit, :id => @story.id, :format => :js
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :edit, :id => @story.id, :format => :js
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :edit, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @story.id
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          get :edit, :id => @story.id
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+  end
 
-  describe '閲覧に於いて' do
+  describe '更新に於いて' do
+    before do
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      @attr = FactoryGirl.attributes_for(:story, :t => 0)
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'モデルに編集取得依頼する' do
+        Story.stub(:edit).with(any_args).and_return(@story)
+        Story.should_receive(:edit).exactly(1)
+        put :update, :id => @story.id, :story => @attr
+      end
+      it 'POSTデータから、カラム値を復元している' do
+        Story.any_instance.stub(:store).and_return(true)
+        Story.any_instance.should_receive(:attributes=).exactly(1)
+        put :update, :id => @story.id, :story => @attr
+      end
+      it '上書き補充を依頼する' do
+        Story.any_instance.should_receive(:overwrite).exactly(1)
+        put :update, :id => @story.id, :story => @attr
+      end
+      it 'モデルに保存依頼する' do
+        Story.any_instance.should_receive(:store).exactly(1)
+        put :update, :id => @story.id, :story => @attr
+      end
+      it "@storyに作成されたストーリーを保持していて、それがDBにある" do
+        put :update, :id => @story.id, :story => @attr
+        assigns(:story).should be_a(Story)
+        assigns(:story).should be_persisted
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          Story.any_instance.stub(:store).and_return(true)
+          put :update, :id => @story.id, :story => @attr
+          response.status.should eq 302
+        end
+        it '更新されたストーリーの表示へページ位置を指定して遷移する' do
+#          Story.any_instance.stub(:store).and_return(true)
+          put :update, :id => @story.id, :story => @attr
+          response.should redirect_to(play_story_path(@story, :page => 1))
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+#          Story.any_instance.stub(:store).and_return(true)
+          put :update, :id => @story.id, :story => @attr, :format => :json
+          response.should be_success 
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          put :update, :id => @story.id, :story => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          put :update, :id => @story.id, :story => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          put :update, :id => @story.id, :story => @attr, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          put :update, :id => @story.id, :story => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          put :update, :id => @story.id, :story => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          put :update, :id => @story.id, :story => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          put :update, :id => @story.id, :story => @attr
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          put :update, :id => @story.id, :story => @attr
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+    context '検証、保存に失敗した' do
+      before do
+        Story.any_instance.stub(:store).and_return(false)
+      end
+      it "指定のコマを保持している" do
+        put :update, :id => @story.id, :story => @attr
+        assigns(:story).should eq @story
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          put :update, :id => @story.id, :story => @attr
+          response.status.should eq 200
+        end
+        it '編集ページを描画する' do
+          put :update, :id => @story.id, :story => @attr
+          response.should render_template("edit")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード422 unprocessable_entity を返す' do
+          put :update, :id => @story.id, :story => @attr, :format => :json
+          response.status.should eq 422
+        end
+        it '応答メッセージUnprocessable Entityを返す' do
+          put :update, :id => @story.id, :story => @attr, :format => :json
+          response.message.should match(/Unprocessable/)
+        end
+      end
+    end
+  end
+
+  describe '削除に於いて' do
+    before do
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      sign_in @user
+      Story.stub(:edit).and_return(@story)
+    end
+    context '事前チェックしておく' do
+      before do
+        Story.stub(:edit).with(any_args()).and_return @story
+        Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true)
+      end
+      it 'ストーリーモデルに編集取得を問い合わせている' do
+        Story.should_receive(:edit).exactly(1)
+        delete :destroy, :id => @story.id
+      end
+      it 'モデルに削除を依頼する' do
+        Story.any_instance.should_receive(:destroy_and_shorten).exactly(1)
+        delete :destroy, :id => @story.id
+      end
+      it '@storyにアレを取得している' do
+        delete :destroy, :id => @story.id
+        assigns(:story).id.should eq(@story.id)
+      end
+    end
+    context 'つつがなく終わるとき' do
+      before do
+        Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true)
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'コミック単体表示ページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.should redirect_to(comic_path(@comic))
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.should be_success
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+    context '削除に失敗したとき' do
+      before do
+        Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(false)
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'そのコミックの詳細ページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.should redirect_to(story_path(@story))
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード422 unprocessable_entity を返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.status.should eq 422
+        end
+        it '応答メッセージUnprocessable Entityを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.message.should match(/Unprocessable/)
+        end
+      end
+    end
+=begin
+    context '対象ストーリーがないとき' do
+    end
+    context '他人のストーリーだったとき' do
+    end
+=end
+  end
+  
+else
+  describe '一覧表示に於いて' do
+    before do
+      sign_in @user
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      Story.stub(:list).and_return([@story, @story, @story])
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'indexテンプレートを描画する' do
+          get :index
+          response.should render_template("index")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :index, :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 :index
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'indexテンプレートを描画する' do
+          get :index
+          response.should render_template("index")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :index, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '単体表示に於いて' do
     before do
-      @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-      Comic.stub(:show).and_return(@comic)
       sign_in @user
-    end
-    context '事前チェックする' do
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic)
+      Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic)
+      Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic)
+      Story.stub(:show).with(@story.id.to_s, [nil, nil]).and_return(@story)
+      Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story)
+      Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story)
     end
     context 'つつがなく終わるとき' do
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id
+          response.should be_success
+        end
+        it 'showテンプレートを描画する' do
+          get :show, :id => @story.id
+          response.should render_template("show")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id, :format => :json
+          response.should be_success
+        end
+        it 'jsonデータを返す' do
+          get :show, :id => @story.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
     end
-    context '作家権限がないとき' do
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id
+          response.should be_success
+        end
+        it 'showテンプレートを描画する' do
+          get :show, :id => @story.id
+          response.should render_template("show")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :show, :id => @story.id, :format => :json
+          response.should be_success
+        end
+        it 'jsonデータを返す' do
+          get :show, :id => @story.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
     end
   end
-
-  describe '新規作成フォーム表示に於いて' do
+  
+  describe '閲覧に於いて' do
     before do
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic)
+      Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic)
+      Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic)
+      Story.stub(:count).and_return(10)
+      Story.stub(:play_list).with(any_args).and_return([@story, @story, @story])
       sign_in @user
     end
     context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :new
-        response.should be_success 
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :comic, :id => @comic.id
+          response.should be_success 
+        end
+        it 'comicテンプレートを描画する' do
+          get :comic, :id => @comic.id
+          response.should render_template("comic")
+        end
       end
-      it '@storyに新規データを用意している' do
-        get :new
-        assigns(:story).should be_a_new(Story)
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :comic, :id => @comic.id, :format => :json
+          response.should be_success 
+        end
+        it 'jsonデータを返す' do
+          get :comic, :id => @comic.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
       end
-      it 'モデルにデフォルト値補充を依頼している' do
-        Story.any_instance.should_receive(:supply_default).exactly(1)
-        get :new
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :comic, :id => @comic.id
+          response.should be_success 
+        end
+        it 'comicテンプレートを描画する' do
+          get :comic, :id => @comic.id
+          response.should render_template("comic")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :comic, :id => @comic.id, :format => :json
+          response.should be_success 
+        end
+        it 'jsonデータを返す' do
+          get :comic, :id => @comic.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
       end
+    end
+  end
+
+  describe '新規作成フォーム表示に於いて' do
+    before do
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
       context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new
+          response.should be_success 
+        end
         it 'newテンプレートを描画する' do
           get :new
           response.should render_template("new")
         end
       end
       context 'js形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new, :format => :js
+          response.should be_success 
+        end
         it 'new.jsテンプレートを描画する' do
           get :new, :format => :js
           response.should render_template("new")
         end
       end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :new, :format => :json
+          response.should be_success 
+        end
+        it 'jsonデータを返す' do
+          get :new, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -70,13 +1196,13 @@ describe StoriesController do
           response.body.should redirect_to '/users/sign_in'
         end
       end
-      context 'js形式' do
+      context 'json形式' do
         it 'ステータスコード401 Unauthorizedを返す' do
-          get :new, :format => :js
+          get :new, :format => :json
           response.status.should eq 401
         end
         it '応答メッセージにUnauthorizedを返す' do
-          get :new, :format => :js
+          get :new, :format => :json
           response.message.should match(/Unauthorized/)
         end
       end
@@ -85,32 +1211,10 @@ describe StoriesController do
   
   describe '新規作成に於いて' do
     before do
-      @attr = Factory.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id)
+      @attr = FactoryGirl.attributes_for :story, :t => nil, :comic_id => @comic.id
       sign_in @user
     end
     context 'つつがなく終わるとき' do
-      it 'デフォルト値補充を依頼する' do
-        Story.any_instance.should_receive(:supply_default).exactly(1)
-        post :create, :story => @attr
-      end
-      it 'POSTデータから、カラム値を復元している' do
-        Story.any_instance.stub(:store).and_return(true)
-        Story.any_instance.should_receive(:attributes=).exactly(1)
-        post :create, :story => @attr
-      end
-      it '上書き補充を依頼する' do
-        Story.any_instance.should_receive(:overwrite).exactly(1)
-        post :create, :story => @attr
-      end
-      it 'モデルに保存依頼する' do
-        Story.any_instance.should_receive(:store).exactly(1)
-        post :create, :story => @attr
-      end
-      it "@storyに作成されたコマを保持していて、それがDBにある" do
-        post :create, :story => @attr
-        assigns(:story).should be_a(Story)
-        assigns(:story).should be_persisted
-      end
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Story.any_instance.stub(:store).and_return(true)
@@ -120,7 +1224,7 @@ describe StoriesController do
         it 'コミックのストーリー表示へ遷移する' do
 #          Story.any_instance.stub(:store).and_return(true)
           post :create, :story => @attr
-          response.should redirect_to(:action => :show, :id => @attr[:comic_id])
+          response.should redirect_to(:action => :comic, :id => @attr[:comic_id])
         end
       end
       context 'json形式' do
@@ -133,14 +1237,9 @@ describe StoriesController do
           post :create, :story => @attr, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'データがアレになっている' do
-          post :create, :story => @attr, :format => :json
-          json = JSON.parse response.body
-          json["t"].should eq 0
-        end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -165,70 +1264,37 @@ describe StoriesController do
         end
       end
     end
-    context '検証、保存に失敗した' do
-      before do
-        Story.any_instance.stub(:store).and_return(false)
-      end
-      it "未保存のコマを保持している" do
-        post :create, :story => @attr
-        assigns(:story).should be_a_new(Story)
-      end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          post :create, :story => @attr
-          response.status.should eq 200
-        end
-        it '新規ページを描画する' do
-          post :create, :story => @attr
-          response.should render_template("new")
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード422 unprocessable_entity を返す' do
-          post :create, :story => @attr, :format => :json
-          response.status.should eq 422
-        end
-        it '応答メッセージUnprocessable Entityを返す' do
-          post :create, :story => @attr, :format => :json
-          response.message.should match(/Unprocessable/)
-        end
-      end
-    end
   end
 
   describe '編集フォーム表示に於いて' do
     before do
-      @story = Factory :story, :author_id => @author.id
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
       sign_in @user
       Story.stub(:show).and_return(@story)
     end
     context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :edit, :id => @story.id
-        response.should be_success 
-      end
-      it 'コマモデルに単体取得を問い合わせている' do
-        Story.should_receive(:show).exactly(1)
-        get :edit, :id => @story.id
-      end
-      it '@storyにデータを用意している' do
-        get :edit, :id => @story.id
-        assigns(:story).should eq @story
-      end
       context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :edit, :id => @story.id
+          response.should be_success 
+        end
         it 'editテンプレートを描画する' do
           get :edit, :id => @story.id
           response.should render_template("edit")
         end
       end
       context 'js形式' do
+        it 'ステータスコード200 OKを返す' do
+          get :edit, :id => @story.id, :format => :js
+          response.should be_success 
+        end
         it 'edit.jsテンプレートを描画する' do
           get :edit, :id => @story.id, :format => :js
           response.should render_template("edit")
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -257,44 +1323,21 @@ describe StoriesController do
 
   describe '更新に於いて' do
     before do
-      @story = Factory :story, :author_id => @user.author.id
-      @attr = Factory.attributes_for(:story, :author_id => @author.id)
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      @attr = FactoryGirl.attributes_for(:story)
       sign_in @user
     end
     context 'つつがなく終わるとき' do
-      it 'モデルに編集取得依頼する' do
-        Story.stub(:edit).with(any_args).and_return(@story)
-        Story.should_receive(:edit).exactly(1)
-        put :update, :id => @story.id, :story => @attr
-      end
-      it 'POSTデータから、カラム値を復元している' do
-        Story.any_instance.stub(:store).and_return(true)
-        Story.any_instance.should_receive(:attributes=).exactly(1)
-        put :update, :id => @story.id, :story => @attr
-      end
-      it '上書き補充を依頼する' do
-        Story.any_instance.should_receive(:overwrite).exactly(1)
-        put :update, :id => @story.id, :story => @attr
-      end
-      it 'モデルに保存依頼する' do
-        Story.any_instance.should_receive(:store).exactly(1)
-        put :update, :id => @story.id, :story => @attr
-      end
-      it "@storyに作成されたストーリーを保持していて、それがDBにある" do
-        put :update, :id => @story.id, :story => @attr
-        assigns(:story).should be_a(Story)
-        assigns(:story).should be_persisted
-      end
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Story.any_instance.stub(:store).and_return(true)
           put :update, :id => @story.id, :story => @attr
           response.status.should eq 302
         end
-        it 'ã\82³ã\83\9fã\83\83ã\82¯ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼è¡¨ç¤ºã\81¸é\81·ç§»ã\81\99ã\82\8b' do
+        it 'ストーリー表示へ遷移する' do
 #          Story.any_instance.stub(:store).and_return(true)
           put :update, :id => @story.id, :story => @attr
-          response.should redirect_to(:action => :show, :id => @attr[:comic_id])
+          response.should redirect_to(:action => :comic, :id => @attr[:comic_id])
         end
       end
       context 'json形式' do
@@ -305,7 +1348,7 @@ describe StoriesController do
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -330,105 +1373,61 @@ describe StoriesController do
         end
       end
     end
-    context '検証、保存に失敗した' do
+  end
+
+  describe '削除に於いて' do
+    before do
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      sign_in @user
+      Story.stub(:edit).and_return(@story)
+    end
+    context 'つつがなく終わるとき' do
       before do
-        Story.any_instance.stub(:store).and_return(false)
-      end
-      it "指定のコマを保持している" do
-        put :update, :id => @story.id, :story => @attr
-        assigns(:story).should eq @story
+        Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true)
       end
       context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it '閲覧ページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id)
+        end
+      end
+      context 'json形式' do
         it 'ステータスコード200 OKを返す' do
-          put :update, :id => @story.id, :story => @attr
-          response.status.should eq 200
+          delete :destroy, :id => @story.id, :format => :json
+          response.should be_success
         end
-        it '編集ページを描画する' do
-          put :update, :id => @story.id, :story => @attr
-          response.should render_template("edit")
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          delete :destroy, :id => @story.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          delete :destroy, :id => @story.id
+          response.body.should redirect_to '/users/sign_in'
         end
       end
       context 'json形式' do
-        it 'ステータスコード422 unprocessable_entity を返す' do
-          put :update, :id => @story.id, :story => @attr, :format => :json
-          response.status.should eq 422
+        it 'ステータスコード401 Unauthorizedを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.status.should eq 401
         end
-        it '応答メッセージUnprocessable Entityを返す' do
-          put :update, :id => @story.id, :story => @attr, :format => :json
-          response.message.should match(/Unprocessable/)
+        it '応答メッセージにUnauthorizedを返す' do
+          delete :destroy, :id => @story.id, :format => :json
+          response.message.should match(/Unauthorized/)
         end
       end
     end
   end
-
-  describe '削除に於いて' do\r
-    before do\r
-      @story = Factory :story, :author_id => @author.id
-      sign_in @user
-      Story.stub(:edit).and_return(@story)\r
-    end\r
-    context 'つつがなく終わるとき' do\r
-      it 'ストーリーモデルに編集取得を問い合わせている' do\r
-        Story.should_receive(:edit).exactly(1)\r
-        delete :destroy, :id => @story.id\r
-      end\r
-      it '@storyにアレを取得している' do\r
-        delete :destroy, :id => @story.id\r
-        assigns(:story).id.should eq(@story.id)\r
-      end\r
-      it 'そのストーリーを一つのトランザクションで削除する' do\r
-        lambda {\r
-          delete :destroy, :id => @story.id\r
-        }.should change(Story, :count)\r
-      end\r
-      context 'html形式' do\r
-        it 'ステータスコード302 Foundを返す' do\r
-          delete :destroy, :id => @story.id\r
-          response.status.should eq 302\r
-        end\r
-        it 'ストーリー一覧ページへ遷移する' do\r
-          delete :destroy, :id => @story.id\r
-          response.should redirect_to(story_path(@story.comic_id))\r
-        end\r
-      end\r
-      context 'json形式' do\r
-        it 'ステータスコード200 OKを返す' do\r
-          delete :destroy, :id => @story.id, :format => :json\r
-          response.should be_success\r
-        end\r
-      end\r
-    end\r
-    context '作家権限がないとき' do\r
-      before do\r
-        sign_out @user\r
-      end\r
-      context 'html形式' do\r
-        it 'ステータスコード302 Foundを返す' do\r
-          delete :destroy, :id => @story.id\r
-          response.status.should eq 302\r
-        end\r
-        it 'サインインページへ遷移する' do\r
-          delete :destroy, :id => @story.id\r
-          response.body.should redirect_to '/users/sign_in'\r
-        end\r
-      end\r
-      context 'json形式' do\r
-        it 'ステータスコード401 Unauthorizedを返す' do\r
-          delete :destroy, :id => @story.id, :format => :json\r
-          response.status.should eq 401\r
-        end\r
-        it '応答メッセージにUnauthorizedを返す' do\r
-          delete :destroy, :id => @story.id, :format => :json\r
-          response.message.should match(/Unauthorized/)\r
-        end\r
-      end\r
-    end\r
-=begin\r
-    context '対象ストーリーがないとき' do\r
-    end\r
-    context '他人のストーリーだったとき' do\r
-    end\r
-=end\r
-  end\r
-  \r
+  
+end
 end