diff --git a/spec/libraries/controller_actions_spec.rb b/spec/libraries/controller_actions_spec.rb index 5ba4073d56..c53c27e3f3 100644 --- a/spec/libraries/controller_actions_spec.rb +++ b/spec/libraries/controller_actions_spec.rb @@ -26,8 +26,10 @@ end context "with custom current_user_method" do - before do + around do |example| Alchemy.current_user_method = 'current_admin' + example.run + Alchemy.current_user_method = 'current_user' end it "calls the custom method" do @@ -37,16 +39,14 @@ end context "with not implemented current_user_method" do - before do + around do |example| Alchemy.current_user_method = 'not_implemented_method' - end - - after do + example.run Alchemy.current_user_method = 'current_user' end it "raises an error" do - expect{ + expect { controller.send :current_alchemy_user }.to raise_error(Alchemy::NoCurrentUserFoundError) end @@ -60,6 +60,8 @@ after do # We must never change the app's locale expect(::I18n.locale).to eq(:en) + # Reset the current language so its fresh for every subsequent test + RequestStore.store[:alchemy_current_language] = nil end context "with a Language argument" do