OSDN Git Service

Merge branch 'v04' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v04license
authoryasushiito <yas@pen-chan.jp>
Sat, 30 Jun 2012 03:44:09 +0000 (12:44 +0900)
committeryasushiito <yas@pen-chan.jp>
Sat, 30 Jun 2012 03:44:09 +0000 (12:44 +0900)
.gitignore
config/application.rb
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/picture_io.yml.org [new file with mode: 0644]
spec/models/artist_spec.rb
spec/models/comic_spec.rb
spec/models/original_picture_spec.rb
spec/models/panel_spec.rb
spec/models/resource_picture_spec.rb

index 1cf8695..69e2885 100644 (file)
@@ -6,5 +6,6 @@ tmp/
 .sass-cache/
 public/image/*
 config/aws.yaml
+config/picture_io.yml
 config/test_layout
 lib/test/temp/
index c752cfa..00a00f7 100644 (file)
@@ -57,6 +57,14 @@ config.assets.initialize_on_precompile = false
     config.autoload_paths += %W(#{config.root}/lib/validators)
   end
 end
+y = YAML.load(open(Rails.root + 'config/picture_io.yml').read)
+require y[Rails.env]["adapter"]
+pio = PictureIO.const_get y[Rails.env]["io"]
+PictureIO.setup do |config|
+  config.original_picture_io = pio.new y[Rails.env]["original_picture"]
+  config.resource_picture_io = pio.new y[Rails.env]["resource_picture"]
+  config.system_picture_io = pio.new y[Rails.env]["system_picture"]
+end
 module ActiveRecord
   class Forbidden < ActiveRecordError
   end
index 6820832..90b4815 100644 (file)
@@ -29,12 +29,6 @@ Pettanr::Application.configure do
   config.assets.debug = true
 end
 
-require 'local_picture'
-PictureIO.setup do |config|
-  config.original_picture_io = PictureIO::LocalPicture.new '/sites/original/pettanr/'
-  config.resource_picture_io = PictureIO::LocalPicture.new  '/sites/resource/pettanr/'
-  config.system_picture_io = PictureIO::LocalPicture.new  '/sites/system/pettanr/'
-end
 module Pettanr
   if File.exist? Rails.root + 'config/test_layout'
     TestLayout = 'test'
index bce780b..b80671e 100644 (file)
@@ -66,9 +66,3 @@ AWS::S3::Base.establish_connection!(
   :access_key_id => y["access_key_id"], 
   :secret_access_key => y["secret_access_key"]
 )
-require 's3_picture'
-PictureIO.setup do |config|
-  config.original_picture_io = PictureIO::S3Picture.new 'pettanr-original'
-  config.resource_picture_io = PictureIO::S3Picture.new 'pettanr-stable'
-  config.system_picture_io = PictureIO::S3Picture.new  'pettanr-system'
-end
index d50c384..e05e0f3 100644 (file)
@@ -38,12 +38,6 @@ Pettanr::Application.configure do
   config.active_support.deprecation = :stderr
 end
 
-require 'local_picture'
-PictureIO.setup do |config|
-  config.original_picture_io = PictureIO::LocalPicture.new '/sites/original/pettanr/'
-  config.resource_picture_io = PictureIO::LocalPicture.new  '/sites/resource/pettanr/'
-  config.system_picture_io = PictureIO::LocalPicture.new  '/sites/system/pettanr/'
-end
 module Pettanr
   if File.exist? Rails.root + 'config/test_layout'
     TestLayout = 'test'
diff --git a/config/picture_io.yml.org b/config/picture_io.yml.org
new file mode 100644 (file)
index 0000000..d1399fe
--- /dev/null
@@ -0,0 +1,20 @@
+development:
+  adapter: local_picture
+  io: LocalPicture
+  original_picture: /pettanr/dev/o/
+  resource_picture: /pettanr/dev/r/
+  system_picture: /pettanr/dev/s/
+
+test:
+  adapter: local_picture
+  io: LocalPicture
+  original_picture: /pettanr/test/o/
+  resource_picture: /pettanr/test/r/
+  system_picture: /pettanr/test/s/
+
+production:
+  adapter: s3_picture
+  io: S3Picture
+  original_picture: pettanr-original
+  resource_picture: pettanr-picture
+  system_picture: pettanr-system
index 4a4b83c..4993cbb 100644 (file)
@@ -96,16 +96,16 @@ describe Artist do
       c.should eq [@artist]
     end
     it '時系列で並んでいる' do
-      n = Factory :artist, :author_id => @author.id, :name => 'artist'
+      n = Factory :artist, :author_id => @author.id, :name => 'artist', :updated_at => Time.now + 100
       l = Artist.list
       l.should eq [n, @artist]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @artist2 = Factory :artist, :author_id => @author.id, :name => 'artist2'
-        @artist3 = Factory :artist, :author_id => @author.id, :name => 'artist3'
-        @artist4 = Factory :artist, :author_id => @author.id, :name => 'artist4'
-        @artist5 = Factory :artist, :author_id => @author.id, :name => 'artist5'
+        @artist2 = Factory :artist, :author_id => @author.id, :name => 'artist2', :updated_at => Time.now + 100
+        @artist3 = Factory :artist, :author_id => @author.id, :name => 'artist3', :updated_at => Time.now + 200
+        @artist4 = Factory :artist, :author_id => @author.id, :name => 'artist4', :updated_at => Time.now + 300
+        @artist5 = Factory :artist, :author_id => @author.id, :name => 'artist5', :updated_at => Time.now + 400
         Artist.stub(:default_page_size).and_return(2)
       end
       it '通常は2件を返す' do
index 599f943..36aa921 100644 (file)
@@ -216,16 +216,16 @@ describe Comic do
       c.should eq [@comic]
     end
     it '時系列で並んでいる' do
-      v = Factory :visible_comic, :author_id => @author.id
+      v = Factory :visible_comic, :author_id => @author.id, :updated_at => Time.now + 100
       c = Comic.list
       c.should eq [v, @comic]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @comic2 = Factory :visible_comic, :author_id => @author.id
-        @comic3 = Factory :editable_comic, :author_id => @author.id
-        @comic4 = Factory :normal_comic, :author_id => @author.id
-        @comic5 = Factory :editable_comic, :author_id => @author.id
+        @comic2 = Factory :visible_comic, :author_id => @author.id, :updated_at => Time.now + 100
+        @comic3 = Factory :editable_comic, :author_id => @author.id, :updated_at => Time.now + 200
+        @comic4 = Factory :normal_comic, :author_id => @author.id, :updated_at => Time.now + 300
+        @comic5 = Factory :editable_comic, :author_id => @author.id, :updated_at => Time.now + 400
         Comic.stub(:default_page_size).and_return(2)
       end
       it '通常は2件を返す' do
index a6fc248..0ccc021 100644 (file)
@@ -271,16 +271,16 @@ describe OriginalPicture do
       pic.should eq [@op]
     end
     it '時系列で並んでいる' do
-      newpic = Factory :original_picture, :artist_id => @artist.id
+      newpic = Factory :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
       pic = OriginalPicture.list @artist.id
       pic.should eq [newpic, @op]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @op2 = Factory :original_picture, :artist_id => @artist.id
-        @op3 = Factory :original_picture, :artist_id => @artist.id
-        @op4 = Factory :original_picture, :artist_id => @artist.id
-        @op5 = Factory :original_picture, :artist_id => @artist.id
+        @op2 = Factory :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 100
+        @op3 = Factory :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 200
+        @op4 = Factory :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 300
+        @op5 = Factory :original_picture, :artist_id => @artist.id, :updated_at => Time.now + 400
         OriginalPicture.stub(:default_page_size).and_return(2)
       end
       it '通常は2件を返す' do
index 09d08b0..4e54620 100644 (file)
@@ -519,16 +519,16 @@ describe Panel do
       pl.should eq [@panel]\r
     end\r
     it '時系列で並んでいる' do\r
-      npl = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 1\r
+      npl = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 1, :updated_at => Time.now + 100\r
       pl = Panel.list\r
       pl.should eq [npl, @panel]\r
     end\r
     context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
       before do\r
-        @npl2 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 1\r
-        @npl3 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 2\r
-        @npl4 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 3\r
-        @npl5 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 4\r
+        @npl2 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 1, :updated_at => Time.now + 100\r
+        @npl3 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 2, :updated_at => Time.now + 200\r
+        @npl4 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 3, :updated_at => Time.now + 300\r
+        @npl5 = Factory :panel, :comic_id => @comic.id, :author_id => @author.id, :t => 4, :updated_at => Time.now + 400\r
         Panel.stub(:default_page_size).and_return(2)\r
       end\r
       it '通常は2件を返す' do\r
index a1ad7c8..28a3430 100644 (file)
@@ -281,20 +281,20 @@ describe ResourcePicture do
     end
     it '時系列で並んでいる' do
       nop = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
-      nrp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop.id
+      nrp = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop.id, :updated_at => Time.now + 100
       pic = ResourcePicture.list
       pic.should eq [nrp, @rp]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
         nop2 = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
-        @nrp2 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop2.id
+        @nrp2 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop2.id, :updated_at => Time.now + 100
         nop3 = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
-        @nrp3 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop3.id
+        @nrp3 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop3.id, :updated_at => Time.now + 200
         nop4 = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
-        @nrp4 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop4.id
+        @nrp4 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop4.id, :updated_at => Time.now + 300
         nop5 = Factory :original_picture, :artist_id => @artist.id, :license_id => @license.id
-        @nrp5 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop5.id
+        @nrp5 = Factory :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => nop5.id, :updated_at => Time.now + 400
         ResourcePicture.stub(:default_page_size).and_return(2)
       end
       it '通常は2件を返す' do