OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / controllers / scrolls_controller_spec.rb
index a3294f9..267879a 100644 (file)
@@ -4,19 +4,16 @@ require 'spec_helper'
 describe ScrollsController do
   before do
     @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
   end
   
 if Manifest.manifest.magic_numbers['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
-      Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
-      sign_in @user
+      #@scroll = FactoryGirl.create :scroll_hello
+      #@author_yas = @scroll.author
+      @author_yas =  FactoryGirl.create :yas_with_scrolls
+      @user_yas = @author_yas.user
+      sign_in @user_yas
     end
     context 'つつがなく終わるとき' do
       it 'ステータスコード200 OKを返す' do
@@ -42,7 +39,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     end
     context 'ユーザ権限がないとき' do
       before do
-        sign_out @user
+        sign_out @user_yas
       end
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
@@ -67,7 +64,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     end
     context 'ユーザ権限はないが管理者権限があるとき' do
       before do
-        sign_out @user
+        sign_out @user_yas
         sign_in @admin
       end
       it 'ステータスコード200 OKを返す' do
@@ -77,7 +74,9 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     end
     context 'ユーザだが作家登録していないとき' do
       before do
-        @author.destroy
+        sign_out @user_yas
+        @user_ghost = FactoryGirl.create :user_ghost
+        sign_in @user_ghost
       end
       context 'html形式' do
         it 'ステータスコード200 OKを返す' do
@@ -90,7 +89,9 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
   
   describe '単体表示に於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id, :title => 'normal'
+      @scroll = FactoryGirl.create :scroll_hello
+      @author_yas = @scroll.author
+      @user_yas = @author_yas.user
       Scroll.stub(:show).and_return(@scroll)
       sign_in @user
     end
@@ -99,10 +100,6 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
         get :show, :id => @scroll.id
         response.should be_success
       end
-      it 'スクロールモデルに単体取得を問い合わせている' do
-        Scroll.should_receive(:show).exactly(1)
-        get :show
-      end
       it '@scrollにアレを取得している' do
         get :show, :id => @scroll.id
         assigns(:scroll).id.should eq(@scroll.id)
@@ -118,21 +115,11 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
           get :show, :id => @scroll.id, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'スクロールモデルにjson単体出力オプションを問い合わせている' do
-          Scroll.should_receive(:show_json_opt).exactly(1)
-          get :show, :id => @scroll.id, :format => :json
-        end
-        it 'データがアレになっている' do
-          get :show, :id => @scroll.id, :format => :json
-          json = JSON.parse response.body
-          json["title"].should match(/normal/)
-          json["visible"].should_not be_nil
-        end
       end
     end
     context 'ユーザ権限がないとき' do
       before do
-        sign_out @user
+        sign_out @user_yas
       end
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
@@ -157,7 +144,7 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     end
     context 'ユーザ権限はないが管理者権限があるとき' do
       before do
-        sign_out @user
+        sign_out @user_yas
         sign_in @admin
       end
       it 'ステータスコード200 OKを返す' do
@@ -167,7 +154,9 @@ if Manifest.manifest.magic_numbers['run_mode'] == 1
     end
     context 'ユーザだが作家登録していないとき' do
       before do
-        @author.destroy
+        sign_out @user_yas
+        @user_ghost = FactoryGirl.create :user_ghost
+        sign_in @user_ghost
       end
       context 'html形式' do
         it 'ステータスコード200 OKを返す' do