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