fixed small issue in albums#update anad added corressponding controller test
This commit is contained in:
parent
32fc6212ab
commit
05808456d8
3 changed files with 29 additions and 1 deletions
|
|
@ -45,7 +45,7 @@ class AlbumsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@album = Album.find_params_by_id params[:id]
|
@album = Album.find_by_id params[:id]
|
||||||
if @album.update_attributes params[:album]
|
if @album.update_attributes params[:album]
|
||||||
flash[:notice] = "Album #{@album.name} successfully edited."
|
flash[:notice] = "Album #{@album.name} successfully edited."
|
||||||
respond_with @album
|
respond_with @album
|
||||||
|
|
|
||||||
23
spec/controllers/albums_controller_spec.rb
Normal file
23
spec/controllers/albums_controller_spec.rb
Normal 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
|
||||||
|
|
@ -22,6 +22,11 @@ Factory.define :person do |p|
|
||||||
p.serialized_key OpenSSL::PKey::RSA.generate(1024).public_key.export
|
p.serialized_key OpenSSL::PKey::RSA.generate(1024).public_key.export
|
||||||
end
|
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|
|
Factory.define :person_with_private_key, :parent => :person do |p|
|
||||||
p.serialized_key OpenSSL::PKey::RSA.generate(1024).export
|
p.serialized_key OpenSSL::PKey::RSA.generate(1024).export
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue