forked from yoon/radiant-top-level-page-extension
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic specs for page controller
- Loading branch information
Mark Yoon
committed
Oct 22, 2008
1 parent
6e516f6
commit 36495a3
Showing
3 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
require File.dirname(__FILE__) + '/../../spec_helper' | ||
|
||
describe Admin::PageController do | ||
scenario :top_level_page_users, :pages | ||
|
||
integrate_views | ||
|
||
before :each do | ||
login_as :top_level_set | ||
end | ||
|
||
it "should allow you to view the index" do | ||
pending | ||
get :index | ||
response.should be_success | ||
assigns(:homepage).should be_kind_of(Page) | ||
assigns(:homepage).title.should == "Child" | ||
end | ||
|
||
it "should allow the index to render even with there are no pages" do | ||
pending | ||
Page.destroy_all | ||
get :index | ||
response.should be_success | ||
assigns(:homepage).should be_nil | ||
end | ||
|
||
it "should show the tree partialy expanded on the index" do | ||
pending | ||
it "should show the tree with Child, but not Home" do | ||
get :index | ||
response.should be_success | ||
assert_rendered_nodes_where { |page| [nil, page_id(:home)].include?(page.parent_id) } | ||
response.should have_tag("tr#page-#{page_id(:child)}") | ||
response.should_not have_tag("tr#page-#{page_id(:home)}") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class TopLevelPageUsersScenario < Scenario::Base | ||
# uses :users | ||
|
||
def load | ||
create_user "TopLevelSet", :page_id => Page.find_by_title("Child").id | ||
create_user "TopLevelNil" | ||
end | ||
|
||
helpers do | ||
def create_user(name, attributes={}) | ||
create_model :user, name.symbolize, user_attributes(attributes.update(:name => name)) | ||
end | ||
def user_attributes(attributes={}) | ||
name = attributes[:name] || "John Doe" | ||
symbol = name.symbolize | ||
attributes = { | ||
:name => name, | ||
:email => "#{symbol}@example.com", | ||
:login => symbol.to_s, | ||
:password => "password" | ||
}.merge(attributes) | ||
attributes[:password_confirmation] = attributes[:password] | ||
attributes | ||
end | ||
def user_params(attributes={}) | ||
password = attributes[:password] || "password" | ||
user_attributes(attributes).update(:password => password, :password_confirmation => password) | ||
end | ||
|
||
def login_as(user) | ||
login_user = user.is_a?(User) ? user : users(user) | ||
flunk "Can't login as non-existing user #{user.to_s}." unless login_user | ||
request.session['user_id'] = login_user.id | ||
login_user | ||
end | ||
|
||
def logout | ||
request.session['user_id'] = nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class TopLevelPageUsersScenario < Scenario::Base | ||
|
||
def load | ||
create_user "TopLevelSet", :page_id => page_id("Child") | ||
create_user "TopLevelNil" | ||
create_user "Admin", :admin => true | ||
create_user "Developer", :developer => true | ||
create_user "Non-admin", :admin => false | ||
end | ||
|
||
helpers do | ||
def create_user(name, attributes={}) | ||
create_model :user, name.symbolize, user_attributes(attributes.update(:name => name)) | ||
end | ||
def user_attributes(attributes={}) | ||
name = attributes[:name] || "John Doe" | ||
symbol = name.symbolize | ||
attributes = { | ||
:name => name, | ||
:email => "#{symbol}@example.com", | ||
:login => symbol.to_s, | ||
:password => "password" | ||
}.merge(attributes) | ||
attributes[:password_confirmation] = attributes[:password] | ||
attributes | ||
end | ||
def user_params(attributes={}) | ||
password = attributes[:password] || "password" | ||
user_attributes(attributes).update(:password => password, :password_confirmation => password) | ||
end | ||
|
||
def login_as(user) | ||
login_user = user.is_a?(User) ? user : users(user) | ||
flunk "Can't login as non-existing user #{user.to_s}." unless login_user | ||
request.session['user_id'] = login_user.id | ||
login_user | ||
end | ||
|
||
def logout | ||
request.session['user_id'] = nil | ||
end | ||
end | ||
end |