Skip to content

Commit

Permalink
restore alert checking functionality, specs to make sure
Browse files Browse the repository at this point in the history
  • Loading branch information
cmar authored and radar committed Mar 12, 2012
1 parent 07356d6 commit 9622740
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/app/controllers/spree/admin/base_controller.rb
Expand Up @@ -5,6 +5,8 @@ class BaseController < Spree::BaseController
helper 'spree/admin/navigation'
layout '/spree/layouts/admin'

before_filter :check_alerts unless Rails.env.development?

protected
def check_alerts
return unless current_user and should_check_alerts?
Expand Down
30 changes: 30 additions & 0 deletions core/spec/controllers/spree/admin/base_controller_spec.rb
@@ -0,0 +1,30 @@
# Spree's rpsec controller tests get the Spree::ControllerHacks
# we don't need those for the anonymous controller here, so
# we call process directly instead of get
require 'spec_helper'

describe Spree::Admin::BaseController do

controller(Spree::Admin::BaseController) do
def index
render :text => 'test'
end
end

before do
controller.stub :current_user => Factory(:admin_user)
end

describe "check alerts" do
it "checks alerts with before_filter" do
controller.should_receive :check_alerts
process :index
end

it "saves alerts into session" do
Spree::Alert.should_receive(:current).and_return([Spree::Alert.new(:message => "test alert", :severity => 'release')])
process :index
session[:alerts].first.message.should eq "test alert"
end
end
end

0 comments on commit 9622740

Please sign in to comment.