Sha256: dd39e141a3758c421c8f90beb14abc77c2a946272b41488829405de6299deb8c
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
require File.dirname(__FILE__) + "/../../spec_helper" describe Admin::UsersController do dataset :users it "should be a ResourceController" do controller.should be_kind_of(Admin::ResourceController) end it "should handle Users" do controller.class.model_class.should == User end { :get => [:index, :new, :edit, :remove], :post => [:create], :put => [:update], :delete => [:destroy] }.each do |method, actions| actions.each do |action| it "should require login to access the #{action} action" do logout lambda { send(method, action, :id => user_id(:existing)).should require_login } end it "should allow you to access to #{action} action if you are an admin" do lambda { send(method, action, :id => user_id(:existing)) }.should restrict_access(:allow => users(:admin), :url => '/admin/page') end it "should deny you access to #{action} action if you are not an admin" do lambda { send(method, action, :id => user_id(:existing)) }.should restrict_access(:deny => [users(:developer), users(:existing)], :url => '/admin/page') end end end it "should not allow you to delete yourself" do user = users(:admin) login_as user get :remove, { :id => user.id } response.should redirect_to(admin_users_url) flash[:error].should match(/cannot.*self/i) User.find(user.id).should_not be_nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
radiant-0.7.2 | spec/controllers/admin/users_controller_spec.rb |
radiant-0.7.0 | spec/controllers/admin/users_controller_spec.rb |
radiant-0.7.1 | spec/controllers/admin/users_controller_spec.rb |