Merge branch 'master' of github.com:diaspora/diaspora_rails

This commit is contained in:
maxwell 2010-07-20 16:22:08 -07:00
commit dac3c7a8de
7 changed files with 66 additions and 5 deletions

11
app/models/collection.rb Normal file
View file

@ -0,0 +1,11 @@
class Collection
include MongoMapper::Document
key :name, String
belongs_to :person, :class_name => 'Person'
many :photos, :class_name => 'Photo', :foreign_key => :collection_id
validates_presence_of :name
end

View file

@ -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!

View file

@ -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

View file

@ -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'

View file

@ -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; }

View file

@ -274,7 +274,7 @@ li.comment > img.person_picture
#show_photo
img
:width 100%
:max-width 100%

View file

@ -0,0 +1,46 @@
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
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
end