Permalink
Browse files

Stub authorization for admin controllers

  • Loading branch information...
1 parent ad9b3df commit 3263215dbd895472dfbb044a94712d28fff32b0a @radar radar committed May 28, 2012
@@ -1,6 +1,7 @@
require 'spec_helper'
describe Spree::Admin::ImageSettingsController do
+ stub_authorization!
context "updating image settings" do
it "should be able to update paperclip settings" do
@@ -1,6 +1,8 @@
require 'spec_helper'
describe Spree::Admin::MailMethodsController do
+ stub_authorization!
+
let(:order) { mock_model(Spree::Order, :complete? => true).as_null_object }
let(:mail_method) { mock_model(Spree::MailMethod).as_null_object }
@@ -1,6 +1,8 @@
require 'spec_helper'
describe Spree::Admin::ProductsController do
+ stub_authorization!
+
context "#index" do
it "should not allow JSON request without a valid token" do
controller.should_receive(:protect_against_forgery?).at_least(:once).and_return(true)
@@ -1,6 +1,8 @@
require 'spec_helper'
describe Spree::Admin::ReturnAuthorizationsController do
+ stub_authorization!
+
# Regression test for #1370 #3
let!(:order) { create(:order) }
it "can create a return authorization" do
@@ -1,6 +1,8 @@
require 'spec_helper'
describe Spree::Admin::UsersController do
+ stub_authorization!
+
context "#index" do
it "should not allow JSON request without a valid token" do
controller.should_receive(:protect_against_forgery?).at_least(:once).and_return(true)
@@ -1,6 +1,7 @@
require 'spec_helper'
describe Spree::OrdersController do
+ stub_authorization!
let(:user) { create(:user) }
let(:order) { mock_model(Spree::Order, :number => "R123", :reload => nil, :save! => true, :coupon_code => nil, :user => user)}
@@ -0,0 +1,11 @@
+module AuthorizationHelpers
+ def stub_authorization!
+ before do
+ controller.should_receive(:authorize!).twice.and_return(true)
+ end
+ end
+end
+
+RSpec.configure do |config|
+ config.extend AuthorizationHelpers
+end

0 comments on commit 3263215

Please sign in to comment.