[rspec-users] Help in Stubing is_admin? method
Ashley Moran
ashley.moran at patchspace.co.uk
Mon Oct 19 17:22:21 EDT 2009
On 19 Oct 2009, at 21:55, Elza wrote:
> def edit
> @user = User.find(get_param(:id, :integer))
> @user = current_user if !is_admin?
> end
Hi Elza
Am I right thinking your intent here is the same as:
def edit
@user = if is_admin?
User.find(get_param(:id, :integer))
else
current_user
end
end
If so, a hit to /users/5 would edit user 5 if you were an admin user,
but would always edit the logged in user otherwise. Since you have
> should_require_login :get, :edit
as part of the spec, that'd mean you could never be in the latter
situation.
Sorry if this is missing the point (I've had a long day, may have
misread your code...), but I thought I'd better establish your intent
before posting an irrelevant reply about the expectation error.
Ashley
--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
http://aviewfromafar.net/
More information about the rspec-users
mailing list