Created
December 19, 2012 13:20
-
-
Save romulostorel/4336608 to your computer and use it in GitHub Desktop.
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
Failures: | |
1) ApplicationController helper methods for current school and academic year should return the current academic year when none was filled | |
Failure/Error: expect(subject.current_academic_year).to eq current_academic_year | |
Double received unexpected message :current_academic_year with (no args) | |
# ./app/controllers/application_controller.rb:26:in `current_academic_year' | |
# ./spec/controllers/application_controller_spec.rb:67:in `block (3 levels) in <top (required)>' | |
2) ApplicationController helper methods for current school and academic year should return the defined academic year | |
Failure/Error: expect(subject.current_academic_year).to eq academic_year | |
expected: #<RSpec::Mocks::Mock:0x3feca57359e8 @name=nil> | |
got: nil | |
(compared using ==) | |
# ./spec/controllers/application_controller_spec.rb:75:in `block (3 levels) in <top (required)>' |
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
require 'spec_helper' | |
describe ApplicationController do | |
controller do | |
def index | |
render :nothing => true | |
end | |
end | |
it 'should not handle customer connection on test environment' do | |
Rails.stub(:env).and_return(ActiveSupport::StringInquirer.new('test')) | |
Customer.should_receive(:find_by_domain!).never | |
get :index | |
end | |
it 'should not handle customer connection on development environment' do | |
Rails.stub(:env).and_return(ActiveSupport::StringInquirer.new('development')) | |
Customer.should_receive(:find_by_domain!).never | |
get :index | |
end | |
it 'should handle customer connection on production environment' do | |
Rails.stub(:env).and_return(ActiveSupport::StringInquirer.new('production')) | |
customer = double('customer') | |
customer.should_receive(:using_connection) | |
Customer.should_receive(:find_by_domain!).with('test.host').and_return(customer) | |
get :index | |
end | |
it 'should handle customer connection on staging environment' do | |
Rails.stub(:env).and_return(ActiveSupport::StringInquirer.new('staging')) | |
customer = double('customer') | |
customer.should_receive(:using_connection) | |
Customer.should_receive(:find_by_domain!).with('test.host').and_return(customer) | |
get :index | |
end | |
context 'helper methods for current school and academic year' do | |
let :user_setting do | |
double('user setting', :school => 1, :academic_year => 2) | |
end | |
let :current_user do | |
double('current user', :user_setting => user_setting) | |
end | |
it 'should return the school of user setting of current user on method current_school' do | |
controller.stub(:current_user).and_return(current_user) | |
expect(subject.current_school).to eq 1 | |
end | |
it 'should return the current academic year when none was filled' do | |
current_academic_year = double(:id => 1) | |
GeneralParameter.stub(:last).and_return double(:current_academic_year_id => 1) | |
expect(subject.current_academic_year).to eq current_academic_year | |
end | |
it 'should return the defined academic year' do | |
session[:academic_year_id] = 2 | |
academic_year = double(:id => 2) | |
AcademicYear.stub(:find).with(2).and_return academic_year | |
expect(subject.current_academic_year).to eq academic_year | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment