OSDN Git Service

Merge branch 'v05' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v05
[pettanr/pettanr.git] / spec / controllers / provider_statuses_controller_spec.rb
index 8a27652..3af7034 100644 (file)
@@ -369,41 +369,21 @@ describe ProviderStatusesController do
     context '事前チェックしておく' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with(any_args).and_return(nil)
-        ProviderStatusesController.any_instance.stub(:export_url).with(any_args).and_return('http://localhost:3000/demanders/licenses_export/1.json')
-        ProviderStatusesController.any_instance.stub(:export_from_provider).with(any_args).and_return([@license.attributes])
-        ProviderLicense.stub(:import).with(any_args).and_return([])
+        ProviderStatus.stub(:licenses_import).with(any_args).and_return(LicenseImportResult.new([]))
       end
       it '借受状況モデルに単体取得を問い合わせている' do
         ProviderStatus.should_receive(:show).exactly(1)
         get :licenses_import, :id => @ps.id
       end
-      it '日付文字列変換を依頼している' do
-        ProviderStatusesController.any_instance.should_receive(:ymd_to_time).with('20111010').exactly(1)
-        get :licenses_import, :id => @ps.id, :date => '20111010'
-      end
-      it 'エクスポートurl取得を依頼している' do
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with('20111010').and_return(Time.parse('2011/10/10'))
-        ProviderStatusesController.any_instance.should_receive(:export_url).with(@provider.demander_url, 'licenses_export', @ps.token, Time.parse('2011/10/10')).exactly(1)
-        get :licenses_import, :id => @ps.id, :date => '20111010'
-      end
-      it '貸手からのエクスポートを依頼している' do
-        ProviderStatusesController.any_instance.should_receive(:export_from_provider).exactly(1)
-        get :licenses_import, :id => @ps.id
-      end
-      it 'ライセンス対照表モデルにインポートを依頼している' do
-        ProviderLicense.should_receive(:import).exactly(1)
+      it 'インポートを依頼している' do
+        ProviderStatus.any_instance.should_receive(:licenses_import).exactly(1)
         get :licenses_import, :id => @ps.id
       end
     end
     context 'つつがなく終わるとき' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with('20111010').and_return(Time.parse('2011/10/10'))
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with(any_args).and_return(nil)
-        ProviderStatusesController.any_instance.stub(:export_url).with(any_args).and_return('http://localhost:3000/demanders/licenses_export/1.json')
-        ProviderStatusesController.any_instance.stub(:export_from_provider).with(any_args).and_return([@license.attributes])
-        ProviderLicense.stub(:import).with(any_args).and_return([])
+        ProviderStatus.any_instance.stub(:licenses_import).with(any_args).and_return(LicenseImportResult.new([]))
       end
       it 'ステータスコード200 OKを返す' do
         get :licenses_import, :id => @ps.id
@@ -413,9 +393,9 @@ describe ProviderStatusesController do
         get :licenses_import, :id => @ps.id
         assigns(:provider_status).should eq(@ps)
       end
-      it '@failuresにインポート失敗リストを取得している' do
+      it '@import_resultにインポート結果を取得している' do
         get :licenses_import, :id => @ps.id
-        assigns(:failures).should eq([])
+        assigns(:import_result).is_a?(ImportResult).should be_true
       end
       context 'html形式' do
         it 'licenses_importテンプレートを描画する' do
@@ -486,41 +466,21 @@ describe ProviderStatusesController do
     context '事前チェックしておく' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with(any_args).and_return(nil)
-        ProviderStatusesController.any_instance.stub(:export_url).with(any_args).and_return('http://localhost:3000/demanders/artists_export/1.json')
-        ProviderStatusesController.any_instance.stub(:export_from_provider).with(any_args).and_return([@artist.attributes])
-        ProviderArtist.stub(:import).with(any_args).and_return([])
+        ProviderStatus.any_instance.stub(:artists_import).with(any_args).and_return(ArtistImportResult.new([]))
       end
       it '借受状況モデルに単体取得を問い合わせている' do
         ProviderStatus.should_receive(:show).exactly(1)
         get :artists_import, :id => @ps.id
       end
-      it '日付文字列変換を依頼している' do
-        ProviderStatusesController.any_instance.should_receive(:ymd_to_time).with('20111010').exactly(1)
-        get :licenses_import, :id => @ps.id, :date => '20111010'
-      end
-      it 'エクスポートurl取得を依頼している' do
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with('20111010').and_return(Time.parse('2011/10/10'))
-        ProviderStatusesController.any_instance.should_receive(:export_url).with(@provider.demander_url, 'artists_export', @ps.token, Time.parse('2011/10/10')).exactly(1)
-        get :artists_import, :id => @ps.id, :date => '20111010'
-      end
-      it '貸手からのエクスポートを依頼している' do
-        ProviderStatusesController.any_instance.should_receive(:export_from_provider).exactly(1)
-        get :artists_import, :id => @ps.id
-      end
-      it '絵師対照表モデルにインポートを依頼している' do
-        ProviderArtist.should_receive(:import).exactly(1)
+      it 'インポートを依頼している' do
+        ProviderStatus.any_instance.should_receive(:artists_import).exactly(1)
         get :artists_import, :id => @ps.id
       end
     end
     context 'つつがなく終わるとき' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with('20111010').and_return(Time.parse('2011/10/10'))
-        ProviderStatusesController.any_instance.stub(:ymd_to_time).with(any_args).and_return(nil)
-        ProviderStatusesController.any_instance.stub(:export_url).with(any_args).and_return('http://localhost:3000/demanders/artists_export/1.json')
-        ProviderStatusesController.any_instance.stub(:export_from_provider).with(any_args).and_return([@artist.attributes])
-        ProviderArtist.stub(:import).with(any_args).and_return([])
+        ProviderStatus.any_instance.stub(:artists_import).with(any_args).and_return(ArtistImportResult.new([]))
       end
       it 'ステータスコード200 OKを返す' do
         get :artists_import, :id => @ps.id
@@ -530,9 +490,9 @@ describe ProviderStatusesController do
         get :artists_import, :id => @ps.id
         assigns(:provider_status).should eq(@ps)
       end
-      it '@failuresにインポート失敗リストを取得している' do
+      it '@import_resultにインポート結果を取得している' do
         get :artists_import, :id => @ps.id
-        assigns(:failures).should eq([])
+        assigns(:import_result).is_a?(ImportResult).should be_true
       end
       context 'html形式' do
         it 'artists_importテンプレートを描画する' do
@@ -612,27 +572,21 @@ describe ProviderStatusesController do
     context '事前チェックしておく' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:export_by).with(any_args).and_return([])
-        ProviderOriginalPicture.stub(:import).with(any_args).and_return({:original_pictures => [], :pictures => [], :resource_pictures => []})
+        ProviderStatus.any_instance.stub(:original_pictures_import).with(any_args).and_return(OriginalPictureImportResult.new([]))
       end
       it '借受状況モデルに単体取得を問い合わせている' do
         ProviderStatus.should_receive(:show).exactly(1)
         get :original_pictures_import, :id => @ps.id
       end
-      it '貸手からの原画エクスポート,実素材エクスポートを依頼している' do
-        ProviderStatusesController.any_instance.should_receive(:export_by).with(any_args).exactly(2)
-        get :original_pictures_import, :id => @ps.id
-      end
-      it '原画対照表モデルにインポートを依頼している' do
-        ProviderOriginalPicture.should_receive(:import).exactly(1)
+      it 'インポートを依頼している' do
+        ProviderStatus.any_instance.should_receive(:original_pictures_import).exactly(1)
         get :original_pictures_import, :id => @ps.id
       end
     end
     context 'つつがなく終わるとき' do
       before do
         ProviderStatus.any_instance.stub(:status).with(any_args).and_return(1)
-        ProviderStatusesController.any_instance.stub(:export_by).with(any_args).and_return([@opattr])
-        ProviderOriginalPicture.stub(:import).with(any_args).and_return({:original_pictures => [], :pictures => [], :resource_pictures => []})
+        ProviderStatus.any_instance.stub(:original_pictures_import).with(any_args).and_return(OriginalPictureImportResult.new([]))
       end
       it 'ステータスコード200 OKを返す' do
         get :original_pictures_import, :id => @ps.id
@@ -642,12 +596,9 @@ describe ProviderStatusesController do
         get :original_pictures_import, :id => @ps.id
         assigns(:provider_status).should eq(@ps)
       end
-      it '@failuresにインポート失敗リストを取得している' do
+      it '@import_resultにインポート結果を取得している' do
         get :original_pictures_import, :id => @ps.id
-        assigns(:failures).should_not be_nil
-        assigns(:failures)[:original_pictures].should be_empty
-        assigns(:failures)[:pictures].should be_empty
-        assigns(:failures)[:resource_pictures].should be_empty
+        assigns(:import_result).is_a?(ImportResult).should be_true
       end
       context 'html形式' do
         it 'artists_importテンプレートを描画する' do