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:
- 3350 Bytes
1 | require File.dirname(__FILE__) + "/../../spec_helper" |
2 | |
3 | describe Admin::LayoutsController do |
4 | dataset :users, :pages_with_layouts |
5 | |
6 | before :each do |
7 | login_as :designer |
8 | end |
9 | |
10 | it "should be a ResourceController" do |
11 | controller.should be_kind_of(Admin::ResourceController) |
12 | end |
13 | |
14 | it "should handle Layouts" do |
15 | controller.class.model_class.should == Layout |
16 | end |
17 | |
18 | |
19 | describe "show" do |
20 | it "should redirect to the edit action" do |
21 | get :show, :id => 1 |
22 | response.should redirect_to(edit_admin_layout_path(params[:id])) |
23 | end |
24 | |
25 | it "should show xml when format is xml" do |
26 | layout = Layout.first |
27 | get :show, :id => layout.id, :format => "xml" |
28 | response.body.should == layout.to_xml |
29 | end |
30 | end |
31 | |
32 | describe "with invalid page id" do |
33 | [:edit, :remove].each do |action| |
34 | before do |
35 | @parameters = {:id => 999} |
36 | end |
37 | it "should redirect the #{action} action to the index action" do |
38 | get action, @parameters |
39 | response.should redirect_to(admin_layouts_path) |
40 | end |
41 | it "should say that the 'Layout could not be found.' after the #{action} action" do |
42 | get action, @parameters |
43 | flash[:notice].should == 'Layout could not be found.' |
44 | end |
45 | end |
46 | it 'should redirect the update action to the index action' do |
47 | put :update, @parameters |
48 | response.should redirect_to(admin_layouts_path) |
49 | end |
50 | it "should say that the 'Layout could not be found.' after the update action" do |
51 | put :update, @parameters |
52 | flash[:notice].should == 'Layout could not be found.' |
53 | end |
54 | it 'should redirect the destroy action to the index action' do |
55 | delete :destroy, @parameters |
56 | response.should redirect_to(admin_layouts_path) |
57 | end |
58 | it "should say that the 'Layout could not be found.' after the destroy action" do |
59 | delete :destroy, @parameters |
60 | flash[:notice].should == 'Layout could not be found.' |
61 | end |
62 | end |
63 | |
64 | { :get => [:index, :new, :edit, :remove], |
65 | :post => [:create], |
66 | :put => [:update], |
67 | :delete => [:destroy] }.each do |method, actions| |
68 | actions.each do |action| |
69 | it "should require login to access the #{action} action" do |
70 | logout |
71 | lambda { send(method, action).should require_login } |
72 | end |
73 | |
74 | it "should allow access to designers for the #{action} action" do |
75 | lambda { |
76 | send(method, action, :id => layout_id(:main)) |
77 | }.should restrict_access(:allow => [users(:designer)], |
78 | :url => '/admin/pages') |
79 | end |
80 | |
81 | it "should allow access to admins for the #{action} action" do |
82 | lambda { |
83 | send(method, action, :id => layout_id(:main)) |
84 | }.should restrict_access(:allow => [users(:designer)], |
85 | :url => '/admin/pages') |
86 | end |
87 | |
88 | it "should deny non-designers and non-admins for the #{action} action" do |
89 | lambda { |
90 | send(method, action, :id => layout_id(:main)) |
91 | }.should restrict_access(:deny => [users(:non_admin), users(:existing)], |
92 | :url => '/admin/pages') |
93 | end |
94 | end |
95 | end |
96 | |
97 | it "should clear the page cache when saved" do |
98 | Radiant::Cache.should_receive(:clear) |
99 | put :update, :id => layout_id(:utf8), :layout => {:content_type => "application/xhtml+xml;charset=utf8"} |
100 | end |
101 | |
102 | end |