README.rdoc in declarative_authorization-0.5.1 vs README.rdoc in declarative_authorization-0.5.2

- old
+ new

@@ -330,10 +330,16 @@ class Test::Unit::TestCase include Authorization::TestHelper ... end +For using the test helpers with RSpec, just add the following lines to your +spec_helper.rb (somewhere after require 'spec/rails'): + + require 'declarative_authorization/maintenance' + include Authorization::TestHelper + Now, in unit tests, you may deactivate authorization if needed e.g. for test setup and assume certain identities for tests: class EmployeeTest < ActiveSupport::TestCase def test_should_read @@ -345,11 +351,24 @@ Employee.find(:first) end end end end + +Or, with RSpec, it would work like this: + describe Employee do + it "should read" do + without_access_control do + Employee.create(...) + end + with_user(admin) do + Employee.find(:first) + end + end + end + In functional tests, get, posts, etc. may be tested in the name of certain users: get_with admin, :index post_with admin, :update, :employee => {...} @@ -489,13 +508,14 @@ sbartsch at tzi.org = Contributors -Thanks to John Joseph Bachir, Eike Carls, Kai Chen, Erik Dahlstrand, Jeroen van Dijk, -Alexander Dobriakov, Sebastian Dyck, Ari Epstein, Jeremy Friesen, Tim Harper, hollownest, -Daniel Kristensen, Brian Langenfeld, Georg Ledermann, Geoff Longman, Olly Lylo, Mark Mansour, -Thomas Maurer, TJ Singleton, Mike Vincent +Thanks to John Joseph Bachir, Eike Carls, Dennis Blöte, Kai Chen, Erik Dahlstrand, +Jeroen van Dijk, Alexander Dobriakov, Sebastian Dyck, Ari Epstein, Jeremy Friesen, +Tim Harper, hollownest, Daniel Kristensen, Brad Langhorst, Brian Langenfeld, +Georg Ledermann, Geoff Longman, Olly Lylo, Mark Mansour, Thomas Maurer, Sharagoz, +TJ Singleton, Mike Vincent = Licence Copyright (c) 2008 Steffen Bartsch, TZI, Universität Bremen, Germany