Skip to content

Commit

Permalink
Handling gallery creation, including feed activity
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed Oct 9, 2008
1 parent 38792da commit 39043c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/galleries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def new
end

def create
@gallery = current_person.galleries.build(params[:galleries])
@gallery = current_person.galleries.build(params[:gallery])
respond_to do |format|
if @gallery.save
flash[:success] = "Gallery successfully created"
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/activities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def feed_message(activity, recent = false)
if recent
%(new gallery #{gallery_link(activity.item)})
else
%(#{person_link_with_image(person)} added new gallery
%(#{person_link_with_image(person)} added a new gallery
#{gallery_link(activity.item)})
end
when "Photo"
Expand Down Expand Up @@ -156,7 +156,7 @@ def minifeed_message(activity)
when "Person"
%(#{person_link_with_image(person)}'s description changed)
when "Gallery"
%(#{person_link_with_image(person)} added new gallery
%(#{person_link_with_image(person)} added a new gallery
#{gallery_link(activity.item)})
when "Photo"
%(#{person_link_with_image(person)} added new
Expand Down
21 changes: 12 additions & 9 deletions app/models/gallery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,20 @@ def primary_photo_url
end

def thumbnail_url
primary_photo.nil? ? "default_thumbnail.png" : primary_photo.public_filename(:thumbnail)
primary_photo.nil? ? "default_thumbnail.png" :
primary_photo.public_filename(:thumbnail)
end

def icon_url
primary_photo.nil? ? "default_icon.png" : primary_photo.public_filename(:icon)
primary_photo.nil? ? "default_icon.png" :
primary_photo.public_filename(:icon)
end

def bounded_icon_url
primary_photo.nil? ? "default_icon.png" : primary_photo.public_filename(:bounded_icon)
primary_photo.nil? ? "default_icon.png" :
primary_photo.public_filename(:bounded_icon)
end

def log_activity
activity = Activity.create!(:item => self, :person => self.person)
add_activities(:activity => activity, :person => self.person)
end


def short_description
description[0..124]
end
Expand All @@ -77,4 +75,9 @@ def short_description
def handle_nil_description
self.description = "" if description.nil?
end

def log_activity
activity = Activity.create!(:item => self, :person => person)
add_activities(:activity => activity, :person => person)
end
end
1 change: 1 addition & 0 deletions app/models/photo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Photo < ActiveRecord::Base
validates_length_of :title, :maximum => 255, :allow_nil => true
validates_presence_of :person_id
validates_presence_of :gallery_id

after_create :log_activity

def self.per_page
Expand Down
7 changes: 7 additions & 0 deletions spec/controllers/galleries_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
page.get :edit, :id => @gallery
response.should be_success

page.post :create, :gallery => { :title => "foo",
:description => "bar" }
gallery = assigns(:gallery)
gallery.title.should == "foo"
gallery.description.should == "bar"
gallery.person.should == @person

page.delete :destroy, :id => @gallery
@gallery.should_not exist_in_database
end
Expand Down

0 comments on commit 39043c1

Please sign in to comment.