prevents timelines spec to change settings for following specs

pull/517/head
Jens Ulferts 11 years ago
parent 3c6225dc76
commit 9467ca20fe
  1. 6
      spec/models/timeline_spec.rb
  2. 8
      spec/support/settings.rb

@ -36,12 +36,14 @@
ba = FactoryGirl.create(:user, :firstname => 'b', :lastname => 'a')
t = Timeline.new
Setting.user_format = :firstname_lastname
with_settings :user_format => :firstname_lastname do
t.available_responsibles.should == [ab, ba]
end
Setting.user_format = :lastname_firstname
with_settings :user_format => :lastname_firstname do
t.available_responsibles.should == [ba, ab]
end
end
end
end
end

@ -30,7 +30,13 @@
# Runs block with settings specified in options.
# The original settings are restored afterwards.
def with_settings(options, &block)
saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
saved_settings = options.keys.inject({}) do |h, k|
h[k] = Setting[k].is_a?(Symbol) ?
Setting[k] :
Setting[k].dup
h
end
options.each { |k, v| Setting[k] = v }
yield
ensure

Loading…
Cancel
Save