Skip to content

Commit fd468a4

Browse files
committed
Support scope assignment through ENV
1 parent 5800f9b commit fd468a4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/scrooge/profile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def raise_on_missing_attribute?
158158
def configure! #:nodoc:
159159
@orm = configure_with( @options['orm'], [:active_record], :active_record )
160160
@storage = configure_with( @options['storage'], [:memory], :memory )
161-
@scope = configure_with( @options['scope'].to_s, framework.scopes, nil )
161+
@scope = configure_with( @options['scope'].to_s, framework.scopes, ENV['scope'] )
162162
@enabled = configure_with( @options['enabled'], [true, false], false )
163163
@on_missing_attribute = configure_with( @options['on_missing_attribute'], [:reload, :raise], :reload )
164164
reset_backends!

spec/units/scrooge/profile_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,11 @@
6363
@profile.raise_on_missing_attribute?().should equal( false )
6464
end
6565

66+
it "should be able to fallback to scope from the environment if none given" do
67+
@profile.framework.stub!(:scopes).and_return( [] )
68+
ENV['scope'] = 'scope_from_env'
69+
@profile.send(:configure!)
70+
@profile.scope_to.should eql( 'scope_from_env' )
71+
end
72+
6673
end

0 commit comments

Comments
 (0)