Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 3339 Bytes
1 | require File.dirname(__FILE__) + "/../../spec_helper" |
2 | |
3 | describe Admin::UsersController do |
4 | dataset :users |
5 | |
6 | it "should be a ResourceController" do |
7 | controller.should be_kind_of(Admin::ResourceController) |
8 | end |
9 | |
10 | it "should handle Users" do |
11 | controller.class.model_class.should == User |
12 | end |
13 | |
14 | |
15 | describe "show" do |
16 | it "should redirect to the edit action" do |
17 | login_as :admin |
18 | get :show, :id => 1 |
19 | response.should redirect_to(edit_admin_user_path(params[:id])) |
20 | end |
21 | end |
22 | |
23 | describe "with invalid page id" do |
24 | before do |
25 | login_as :admin |
26 | end |
27 | [:edit, :remove].each do |action| |
28 | before do |
29 | @parameters = {:id => 999} |
30 | end |
31 | it "should redirect the #{action} action to the index action" do |
32 | get action, @parameters |
33 | response.should redirect_to(admin_users_path) |
34 | end |
35 | it "should say that the 'User could not be found.' after the #{action} action" do |
36 | get action, @parameters |
37 | flash[:notice].should == 'User could not be found.' |
38 | end |
39 | end |
40 | it 'should redirect the update action to the index action' do |
41 | put :update, @parameters |
42 | response.should redirect_to(admin_users_path) |
43 | end |
44 | it "should say that the 'User could not be found.' after the update action" do |
45 | put :update, @parameters |
46 | flash[:notice].should == 'User could not be found.' |
47 | end |
48 | it 'should redirect the destroy action to the index action' do |
49 | delete :destroy, @parameters |
50 | response.should redirect_to(admin_users_path) |
51 | end |
52 | it "should say that the 'User could not be found.' after the destroy action" do |
53 | delete :destroy, @parameters |
54 | flash[:notice].should == 'User could not be found.' |
55 | end |
56 | end |
57 | |
58 | { :get => [:index, :new, :edit, :remove], |
59 | :post => [:create], |
60 | :put => [:update], |
61 | :delete => [:destroy] }.each do |method, actions| |
62 | actions.each do |action| |
63 | it "should require login to access the #{action} action" do |
64 | logout |
65 | lambda { send(method, action, :id => user_id(:existing)).should require_login } |
66 | end |
67 | |
68 | it "should allow you to access to #{action} action if you are an admin" do |
69 | lambda { |
70 | send(method, action, :id => user_id(:existing)) |
71 | }.should restrict_access(:allow => users(:admin), |
72 | :url => '/admin/page') |
73 | end |
74 | |
75 | it "should deny you access to #{action} action if you are not an admin" do |
76 | lambda { |
77 | send(method, action, :id => user_id(:existing)) |
78 | }.should restrict_access(:deny => [users(:designer), users(:existing)], |
79 | :url => '/admin/page') |
80 | end |
81 | end |
82 | end |
83 | |
84 | it "should not allow you to delete yourself" do |
85 | user = users(:admin) |
86 | login_as user |
87 | get :remove, { :id => user.id } |
88 | response.should redirect_to(admin_users_url) |
89 | flash[:error].should match(/cannot.*self/i) |
90 | User.find(user.id).should_not be_nil |
91 | end |
92 | |
93 | it "should not allow you to remove your own admin privilege" do |
94 | user = users(:admin) |
95 | login_as user |
96 | put :update, { :id => user.id, :user => {:admin => false} } |
97 | response.should redirect_to(admin_users_url) |
98 | flash[:error].should match(/cannot remove yourself from the admin role/i) |
99 | User.find(user.id).admin.should be_true |
100 | end |
101 | end |