fixed small issue in albums#update anad added corressponding controller test

This commit is contained in:
Federico Brubacher 2010-09-16 12:21:08 -03:00
parent 32fc6212ab
commit 05808456d8
3 changed files with 29 additions and 1 deletions

View file

@ -45,7 +45,7 @@ class AlbumsController < ApplicationController
end
def update
@album = Album.find_params_by_id params[:id]
@album = Album.find_by_id params[:id]
if @album.update_attributes params[:album]
flash[:notice] = "Album #{@album.name} successfully edited."
respond_with @album

View file

@ -0,0 +1,23 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3. See
# the COPYRIGHT file.
require File.dirname(__FILE__) + '/../spec_helper'
include ApplicationHelper
describe AlbumsController do
render_views
before do
@user = Factory.create(:user)
@user.aspect(:name => "lame-os")
@album = Factory.create(:album)
sign_in :user, @user
end
it "should update the name of an album" do
sign_in :user, @user
put :update, :id => @album._id, :album => { :name => "new_name"}
@album.reload.name.should eql("new_name")
end
end

View file

@ -22,6 +22,11 @@ Factory.define :person do |p|
p.serialized_key OpenSSL::PKey::RSA.generate(1024).public_key.export
end
Factory.define :album do |p|
p.name "my first album"
p.person { |a| Factory.create(:person) }
end
Factory.define :person_with_private_key, :parent => :person do |p|
p.serialized_key OpenSSL::PKey::RSA.generate(1024).export
end