OSDN Git Service

t#30200:update i18n devise
[pettanr/pettanr.git] / spec / models / author_spec.rb
index c90208e..dfc036e 100644 (file)
@@ -6,7 +6,7 @@ describe Author do
   before do
     @admin = FactoryGirl.create :admin
     @user = FactoryGirl.create( :user_yas)
-    @author = @user.author
+    @author = FactoryGirl.create :author, :user_id => @user.id
   end
 
   describe '検証に於いて' do
@@ -64,7 +64,7 @@ describe Author do
   describe '所持判定に於いて' do
     before do
       @other_user = FactoryGirl.create :user_yas
-#アカウントを作ると連動して作家ができる      @other_author = FactoryGirl.create :author_yas, :user_id => @other_user.id\r
+#アカウントを作ると連動して作家ができる      @other_author = FactoryGirl.create :author_yas, :user_id => @other_user.id
     end
     it '作家自身ならyes' do
       @author.own?(@author).should == true
@@ -85,33 +85,33 @@ describe Author do
         before do
           MagicNumber['run_mode'] = 1
         end
-        it '不許可を返す。' do\r
+        it '不許可を返す。' do
           r = @author.visible?(nil)
           r.should be_false
-        end\r
-      end\r
+        end
+      end
       context 'オープンモードのとき' do
         before do
           MagicNumber['run_mode'] = 0
         end
-        it '許可する' do\r
+        it '許可する' do
           r = @author.visible?(nil)
           r.should be_true
-        end\r
-      end\r
-    end\r
+        end
+      end
+    end
     context '検査対象が作家のとき' do
-      it '許可する' do\r
+      it '許可する' do
         r = @author.visible?(@author)
         r.should == true
-      end\r
-    end\r
+      end
+    end
     context '検査対象がそれ以外のとき' do
-      it '不許可を返す。' do\r
+      it '不許可を返す。' do
         r = @author.visible?(@admin)
         r.should be_false
-      end\r
-    end\r
+      end
+    end
   end
   
   describe '絵師作家判定に於いて' do
@@ -158,20 +158,20 @@ describe Author do
         Author.page_size('1000').should eq Author.max_page_size
       end
     end
-    context 'つつがなく終わるとき' do\r
-      it '一覧取得オプションを利用している' do\r
-        Author.stub(:list_opt).with(any_args).and_return({})\r
-        Author.should_receive(:list_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '一覧取得オプションを利用している' do
+        Author.stub(:list_opt).with(any_args).and_return({})
+        Author.should_receive(:list_opt).with(any_args).exactly(1)
         r = Author.list
-      end\r
-    end\r
+      end
+    end
     it 'リストを返す' do
       r = Author.list
       r.should eq [@author]
     end
     it '作成時系列で並んでいる' do
       @other_user = FactoryGirl.create :user_yas
-      #アカウントを作ると連動して作家ができる
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
       n = @other_user.author
       n.created_at = Time.now + 100
       n.save
@@ -181,19 +181,19 @@ describe Author do
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
         @other_user2 = FactoryGirl.create :user_yas
-        @author2 = @other_user2.author
+        @author2 = FactoryGirl.create :author, :user_id => @other_user2.id
         @author2.created_at = Time.now + 100
         @author2.save
         @other_user3 = FactoryGirl.create :user_yas
-        @author3 = @other_user3.author
+        @author3 = FactoryGirl.create :author, :user_id => @other_user3.id
         @author3.created_at = Time.now + 200
         @author3.save
         @other_user4 = FactoryGirl.create :user_yas
-        @author4 = @other_user4.author
+        @author4 = FactoryGirl.create :author, :user_id => @other_user4.id
         @author4.created_at = Time.now + 300
         @author4.save
         @other_user5 = FactoryGirl.create :user_yas
-        @author5 = @other_user5.author
+        @author5 = FactoryGirl.create :author, :user_id => @other_user5.id
         @author5.created_at = Time.now + 400
         @author5.save
         Author.stub(:default_page_size).and_return(2)
@@ -219,19 +219,19 @@ describe Author do
     context 'DBに5件あって1ページの件数を0件に変えたとして' do
       before do
         @other_user2 = FactoryGirl.create :user_yas
-        @author2 = @other_user2.author
+        @author2 = FactoryGirl.create :author, :user_id => @other_user2.id
         @author2.created_at = Time.now + 100
         @author2.save
         @other_user3 = FactoryGirl.create :user_yas
-        @author3 = @other_user3.author
+        @author3 = FactoryGirl.create :author, :user_id => @other_user3.id
         @author3.created_at = Time.now + 200
         @author3.save
         @other_user4 = FactoryGirl.create :user_yas
-        @author4 = @other_user4.author
+        @author4 = FactoryGirl.create :author, :user_id => @other_user4.id
         @author4.created_at = Time.now + 300
         @author4.save
         @other_user5 = FactoryGirl.create :user_yas
-        @author5 = @other_user5.author
+        @author5 = FactoryGirl.create :author, :user_id => @other_user5.id
         @author5.created_at = Time.now + 400
         @author5.save
         Author.stub(:default_page_size).and_return(2)
@@ -271,53 +271,53 @@ describe Author do
   describe '単体取得に於いて' do
     before do
     end
-    context 'つつがなく終わるとき' do\r
-      it '単体取得オプションを利用している' do\r
-        Author.stub(:show_opt).with(any_args).and_return({})\r
-        Author.should_receive(:show_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '単体取得オプションを利用している' do
+        Author.stub(:show_opt).with(any_args).and_return({})
+        Author.should_receive(:show_opt).with(any_args).exactly(1)
         r = Author.show @author.id, @author
-      end\r
-      it '閲覧許可を問い合わせている' do\r
-        Author.any_instance.stub(:visible?).with(any_args).and_return(true)\r
-        Author.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
+      end
+      it '閲覧許可を問い合わせている' do
+        Author.any_instance.stub(:visible?).with(any_args).and_return(true)
+        Author.any_instance.should_receive(:visible?).with(any_args).exactly(1)
         r = Author.show @author.id, @author
-      end\r
-    end\r
+      end
+    end
     it '指定の作家を返す' do
       r = Author.show @author.id, @author
       r.should eq @author
     end
-    context '閲覧許可が出なかったとき' do\r
-      it '403Forbidden例外を返す' do\r
-        Author.any_instance.stub(:visible?).and_return(false)\r
-        lambda{\r
-          Author.show @author.id, @author\r
-        }.should raise_error(ActiveRecord::Forbidden)\r
-      end\r
-    end\r
-    context '存在しない作家を開こうとしたとき' do\r
-      it '404RecordNotFound例外を返す' do\r
-        lambda{\r
-          Author.show 110, @author\r
-        }.should raise_error(ActiveRecord::RecordNotFound)\r
-      end\r
-    end\r
+    context '閲覧許可が出なかったとき' do
+      it '403Forbidden例外を返す' do
+        Author.any_instance.stub(:visible?).and_return(false)
+        lambda{
+          Author.show @author.id, @author
+        }.should raise_error(ActiveRecord::Forbidden)
+      end
+    end
+    context '存在しない作家を開こうとしたとき' do
+      it '404RecordNotFound例外を返す' do
+        lambda{
+          Author.show 110, @author
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+    end
   end
   describe '編集取得に於いて' do
     before do
     end
-    context 'つつがなく終わるとき' do\r
-      it '単体取得オプションを利用している' do\r
-        Author.stub(:show_opt).with(any_args).and_return({})\r
-        Author.should_receive(:show_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '単体取得オプションを利用している' do
+        Author.stub(:show_opt).with(any_args).and_return({})
+        Author.should_receive(:show_opt).with(any_args).exactly(1)
         r = Author.edit @author.id, @author
-      end\r
-      it '所持判定を問い合わせている' do\r
-        Author.any_instance.stub(:own?).with(any_args).and_return(true)\r
-        Author.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+      end
+      it '所持判定を問い合わせている' do
+        Author.any_instance.stub(:own?).with(any_args).and_return(true)
+        Author.any_instance.should_receive(:own?).with(any_args).exactly(1)
         r = Author.edit @author.id, @author
-      end\r
-    end\r
+      end
+    end
     it '指定の作家を返す' do
       Author.any_instance.stub(:own?).and_return(true)
       r = Author.edit @author.id, @author.id