From 05808456d842cfe7035ebcc882d5e2f97bd8cdf8 Mon Sep 17 00:00:00 2001 From: Federico Brubacher Date: Thu, 16 Sep 2010 12:21:08 -0300 Subject: [PATCH] fixed small issue in albums#update anad added corressponding controller test --- app/controllers/albums_controller.rb | 2 +- spec/controllers/albums_controller_spec.rb | 23 ++++++++++++++++++++++ spec/factories.rb | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 spec/controllers/albums_controller_spec.rb diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index f4d797a46..6432e2a88 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -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 diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb new file mode 100644 index 000000000..ce2bd305d --- /dev/null +++ b/spec/controllers/albums_controller_spec.rb @@ -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 diff --git a/spec/factories.rb b/spec/factories.rb index 918a210f2..4c59631d8 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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