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:
- 2649 Bytes
1 | require File.dirname(__FILE__) + "/../../spec_helper" |
2 | |
3 | describe Admin::WelcomeController do |
4 | dataset :users |
5 | |
6 | it "should redirect to page tree on get to /admin/welcome" do |
7 | get :index |
8 | response.should be_redirect |
9 | response.should redirect_to(admin_pages_path) |
10 | end |
11 | |
12 | it "should render the login screen on get to /admin/login" do |
13 | get :login |
14 | response.should be_success |
15 | response.should render_template("login") |
16 | end |
17 | |
18 | it "should set the current user and redirect when login was successful" do |
19 | post :login, :username_or_email => "admin", :password => "password" |
20 | controller.send(:current_user).should == users(:admin) |
21 | response.should be_redirect |
22 | response.should redirect_to(welcome_url) |
23 | end |
24 | |
25 | it "should render the login template when login failed" do |
26 | controller.should_receive(:announce_invalid_user) # Can't test flash.now! |
27 | post :login, :user => {:login => "admin", :password => "wrong"} |
28 | response.should render_template("login") |
29 | end |
30 | |
31 | describe "remember me" do |
32 | |
33 | before do |
34 | Radiant::Config['session_timeout'] = 2.weeks |
35 | @user = users(:admin) |
36 | controller.stub!(:current_user).and_return(@user) |
37 | end |
38 | |
39 | after do |
40 | post :login, :username_or_email => "admin", :password => "password", :remember_me => 1 |
41 | end |
42 | |
43 | it "should remember user" do |
44 | @user.should_receive(:remember_me) |
45 | end |
46 | |
47 | it "should set cookie" do |
48 | controller.should_receive(:set_session_cookie) |
49 | end |
50 | end |
51 | |
52 | describe "with a logged-in user" do |
53 | before do |
54 | login_as :admin |
55 | end |
56 | |
57 | it "should clear the current user and redirect on logout" do |
58 | controller.should_receive(:current_user=).with(nil) |
59 | get :logout |
60 | response.should be_redirect |
61 | response.should redirect_to(login_url) |
62 | end |
63 | |
64 | it "should forget user on logout" do |
65 | controller.send(:current_user).should_receive(:forget_me) |
66 | get :logout |
67 | end |
68 | |
69 | it "should not show /login again" do |
70 | get :login |
71 | response.should redirect_to(welcome_url) |
72 | end |
73 | |
74 | describe "and a stored location" do |
75 | before do |
76 | session[:return_to] = '/stored/path' |
77 | post :login, :username_or_email => "admin", :password => "password" |
78 | end |
79 | |
80 | it "should redirect" do |
81 | response.should redirect_to('/stored/path') |
82 | end |
83 | |
84 | it "should clear session[:return_to]" do |
85 | session[:return_to].should be_nil |
86 | end |
87 | end |
88 | end |
89 | |
90 | describe "without a user" do |
91 | it "should gracefully handle logout" do |
92 | controller.stub!(:current_member).and_return(nil) |
93 | get :logout |
94 | response.should redirect_to(login_url) |
95 | end |
96 | end |
97 | |
98 | end |