From 7b6289c78ae348a199a09abc71a5b59825c0eb0a Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 20 Jul 2010 11:52:38 -0700 Subject: [PATCH 1/6] Took label out of publisher for photo --- app/views/shared/_publisher.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 78f907600..ccb15f9a7 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -42,7 +42,6 @@ = form_for Photo.new, :html => {:multipart => true} do |f| = f.error_messages %p - %label{:for => "image_form"} Image = f.file_field :image %p = f.submit 'post it!', :class => 'button' From 382caf7adcb323fd79523bf62bcc21a69934b51d Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 20 Jul 2010 11:53:13 -0700 Subject: [PATCH 2/6] Reverting last commit --- app/views/shared/_publisher.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index ccb15f9a7..78f907600 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -42,6 +42,7 @@ = form_for Photo.new, :html => {:multipart => true} do |f| = f.error_messages %p + %label{:for => "image_form"} Image = f.file_field :image %p = f.submit 'post it!', :class => 'button' From afc150c719be16d53efc8fc8ed250351d7860ba7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 20 Jul 2010 11:56:11 -0700 Subject: [PATCH 3/6] Reverting reverrsion --- app/views/shared/_publisher.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 78f907600..ccb15f9a7 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -42,7 +42,6 @@ = form_for Photo.new, :html => {:multipart => true} do |f| = f.error_messages %p - %label{:for => "image_form"} Image = f.file_field :image %p = f.submit 'post it!', :class => 'button' From 2345975f2278ea6fd08af0e8745b17c728c52d3f Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 20 Jul 2010 13:31:01 -0700 Subject: [PATCH 4/6] DG IZ; fixed show photo always expanding to 100% width --- public/stylesheets/application.css | 6 +++--- public/stylesheets/sass/application.sass | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 3b9ad7a11..e7037c671 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -17,9 +17,6 @@ a { a:hover { color: #018790; } -#show_photo img { - width: 100%; } - #flash_notice, #flash_error, #flash_alert { @@ -233,6 +230,9 @@ li.comment > img.person_picture { .request_buttons > li:first-child { margin-right: 1em; } +#show_photo img { + max-width: 100%; } + #debug_info { margin-top: 20px; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index bc2cc58e2..1d9d85fa2 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -274,7 +274,7 @@ li.comment > img.person_picture #show_photo img - :width 100% + :max-width 100% From 1bd2c16ef1233025418b324973a9a5803dad0dbf Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 20 Jul 2010 14:01:56 -0700 Subject: [PATCH 5/6] DG IZ started the collection spec --- app/models/collection.rb | 13 +++++++++++++ app/models/person.rb | 1 + spec/models/collection_spec.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 app/models/collection.rb create mode 100644 spec/models/collection_spec.rb diff --git a/app/models/collection.rb b/app/models/collection.rb new file mode 100644 index 000000000..4184ffdbb --- /dev/null +++ b/app/models/collection.rb @@ -0,0 +1,13 @@ +class Collection + include MongoMapper::Document + + key :name, String + + belongs_to :person, :class_name => 'Person' + + validates_presence_of :name + + #many :posts, :class_name => 'Post', :foreign_key => :collection_id + + +end diff --git a/app/models/person.rb b/app/models/person.rb index 968ba5dd7..be06c0b26 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -16,6 +16,7 @@ class Person one :profile, :class_name => 'Profile' many :posts, :class_name => 'Post', :foreign_key => :person_id + many :collections, :class_name => 'Collection', :foreign_key => :person_id timestamps! diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb new file mode 100644 index 000000000..4e6ef55eb --- /dev/null +++ b/spec/models/collection_spec.rb @@ -0,0 +1,31 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Collection do + before do + @user = Factory.create(:user) + @collection = Collection.new(:name => "test collection") + end + + it 'should belong to a person' do + person = Factory.create(:person) + @collection.person = person + @collection.valid?.should be true + @collection.save + person.collections.count.should == 1 + end + + it 'should require a name' do + @collection.name = "test collection" + @collection.valid?.should be true + + @collection.name = nil + @collection.valid?.should be false + end + + it 'should contain photos' do + + end + + + +end From 51fd87db36c46e24a65026d2951715e5b61e804a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 20 Jul 2010 15:15:11 -0700 Subject: [PATCH 6/6] no ideas why collection saving isn't working... --- app/models/collection.rb | 4 +--- app/models/photo.rb | 4 ++++ spec/models/collection_spec.rb | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/models/collection.rb b/app/models/collection.rb index 4184ffdbb..daaceab05 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -4,10 +4,8 @@ class Collection key :name, String belongs_to :person, :class_name => 'Person' + many :photos, :class_name => 'Photo', :foreign_key => :collection_id validates_presence_of :name - #many :posts, :class_name => 'Post', :foreign_key => :collection_id - - end diff --git a/app/models/photo.rb b/app/models/photo.rb index 70e65cb64..10bd71276 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -2,4 +2,8 @@ class Photo < Post require 'carrierwave/orm/mongomapper' include MongoMapper::Document mount_uploader :image, ImageUploader + + key :collection_id, ObjectId + + belongs_to :collection, :class_name => 'Collection' end diff --git a/spec/models/collection_spec.rb b/spec/models/collection_spec.rb index 4e6ef55eb..fd80f2d7b 100644 --- a/spec/models/collection_spec.rb +++ b/spec/models/collection_spec.rb @@ -23,7 +23,22 @@ describe Collection do end it 'should contain photos' do + collection = Collection.create(:name => "test collection") + + photo = Photo.create(:person => @user) + + puts photo.valid? + puts collection.valid? + + puts photo.inspect + puts collection.photos.inspect + + puts 'asdojasd' + puts photo.collection + puts 'asdojasd' + + collection.photos.count.should == 1 end