Permalink
Browse files

Avoid a bunch of deprecation warnings (stub! > stub) and use engine r…

…outes in spec/controllers
  • Loading branch information...
jomz committed Feb 8, 2014
1 parent 473c191 commit 656f95500eb2b8eb15fe6d5c498863d03ce12a98
@@ -32,33 +32,33 @@
describe 'self.template_name' do
it "should return 'index' when the controller action_name is 'index'" do
- controller.stub!(:action_name).and_return('index')
+ controller.stub(:action_name).and_return('index')
controller.template_name.should == 'index'
end
['new', 'create'].each do |action|
it "should return 'new' when the action_name is #{action}" do
- controller.stub!(:action_name).and_return(action)
+ controller.stub(:action_name).and_return(action)
controller.template_name.should == 'new'
end
end
['edit', 'update'].each do |action|
it "should return 'edit' when the action_name is #{action}" do
- controller.stub!(:action_name).and_return(action)
+ controller.stub(:action_name).and_return(action)
controller.template_name.should == 'edit'
end
end
['remove', 'destroy'].each do |action|
it "should return 'remove' when the action_name is #{action}" do
- controller.stub!(:action_name).and_return(action)
+ controller.stub(:action_name).and_return(action)
controller.template_name.should == 'remove'
end
end
it "should return 'show' when the action_name is show" do
- controller.stub!(:action_name).and_return('show')
+ controller.stub(:action_name).and_return('show')
controller.template_name.should == 'show'
end
it "should return the action_name when the action_name is a non-standard name" do
- controller.stub!(:action_name).and_return('other')
+ controller.stub(:action_name).and_return('other')
controller.template_name.should == 'other'
end
end
@@ -1,9 +1,13 @@
require "spec_helper"
describe Radiant::Admin::ExtensionsController do
-
+ routes { Radiant::Engine.routes }
+
+ test_helper :user
+ include AuthenticationHelper
+
before :each do
- login_as :admin
+ login_as :user
end
it "should require login for all actions" do
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + "/../../spec_helper"
describe Radiant::Admin::LayoutsController do
+ routes { Radiant::Engine.routes }
#dataset :users, :pages_with_layouts
before :each do
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Radiant::Admin::PageFieldsController do
+ routes { Radiant::Engine.routes }
#dataset :users
before do
@@ -3,6 +3,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Radiant::Admin::PagesController do
+ routes { Radiant::Engine.routes }
#dataset :users, :pages
before :each do
@@ -204,23 +205,23 @@
'parts_attributes' => [{'content' => 'TEST', 'id' => body_id.to_s}] } }
}
it 'should render the page with changes' do
- request.stub!(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
+ request.stub(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
post :preview, preview_params
response.body.should eql('TEST')
end
describe 'new child' do
it 'should not save any changes' do
page_count = Page.count
- request.stub!(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
+ request.stub(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
post :preview, preview_params
Page.count.should == page_count
end
end
# TODO: transactional fixtures must be turned off for this to be able to test the transactions properly
# describe 'edit existing page' do
# it 'should not save any changes' do
- # request.stub!(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
+ # request.stub(:referer).and_return("/admin/pages/#{preview_page.id}/edit")
# original_date = preview_page.updated_at
# put :preview, preview_params
# non_updated_page = Page.find(preview_page.id)
@@ -260,7 +261,7 @@
home = pages(:home)
new_page = home.class.new_with_defaults
new_page.parent_id = home.id
- Page.stub!(:new_with_defaults).and_return(new_page)
+ Page.stub(:new_with_defaults).and_return(new_page)
get :new, :page_id => home.id
assigns(:page).should == new_page
end
@@ -277,7 +278,7 @@
it "should instantiate a new page of the given class" do
PagesControllerSpecPage = Class.new(Page)
- PagesControllerSpecPage.stub!(:default_page_parts).and_return(PagePart.new :name => "my_part")
+ PagesControllerSpecPage.stub(:default_page_parts).and_return(PagePart.new :name => "my_part")
get :new, :page_id => page_id(:home), :page_class => 'PagesControllerSpecPage'
assigns(:page).parts.map(&:name).should include('my_part')
end
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + "/../../spec_helper"
describe Radiant::Admin::UsersController do
+ routes { Radiant::Engine.routes }
it "should be paginated" do
Radiant::Admin::UsersController.paginated.should be_true
@@ -1,6 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Radiant::Admin::PreferencesController do
+ routes { Radiant::Engine.routes }
#dataset :users
it "should allow you to view your preferences" do
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Radiant::Admin::ReferencesController do
+ routes { Radiant::Engine.routes }
#dataset :users
before :each do
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe Radiant::SiteController do
+ routes { Radiant::Engine.routes }
#dataset :pages
it "should find and render home page" do
@@ -37,8 +38,8 @@
page = pages(:first)
param_name = WillPaginate::ViewHelpers.pagination_options[:param_name] || :p
pagination_parameters = {param_name => 3, :per_page => 100}
- controller.stub!(:pagination_parameters).and_return(pagination_parameters)
- controller.stub!(:find_page).and_return(page)
+ controller.stub(:pagination_parameters).and_return(pagination_parameters)
+ controller.stub(:find_page).and_return(page)
get :show_page, :url => 'first/'
@@ -137,7 +138,7 @@
end
it "should return a not-modified response when the sent etag matches" do
- response.stub!(:etag).and_return("foobar")
+ response.stub(:etag).and_return("foobar")
request.if_none_match = 'foobar'
get :show_page, :url => '/'
response.response_code.should == 304
@@ -174,7 +175,7 @@
describe "pagination" do
it "should pass through pagination parameters to the page" do
@page = pages(:home)
- Page.stub!(:find_by_path).and_return(@page)
+ Page.stub(:find_by_path).and_return(@page)
@page.should_receive(:pagination_parameters=).with({:page => '3', :per_page => '12'})
get :show_page, :url => '/', :page => '3', :per_page => '12'
end
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + "/../../spec_helper"
describe Radiant::Admin::UsersController do
+ routes { Radiant::Engine.routes }
#dataset :users
it "should be a ResourceController" do
@@ -1,6 +1,7 @@
require File.dirname(__FILE__) + "/../../spec_helper"
describe Radiant::Admin::WelcomeController do
+ routes { Radiant::Engine.routes }
#dataset :users
it "should redirect to page tree on get to /admin/welcome" do
@@ -33,7 +34,7 @@
before do
Radiant::Config['session_timeout'] = 2.weeks
@user = users(:admin)
- controller.stub!(:current_user).and_return(@user)
+ controller.stub(:current_user).and_return(@user)
end
after do
@@ -89,7 +90,7 @@
describe "without a user" do
it "should gracefully handle logout" do
- controller.stub!(:current_member).and_return(nil)
+ controller.stub(:current_member).and_return(nil)
get :logout
response.should redirect_to(login_url)
end

0 comments on commit 656f955

Please sign in to comment.