diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 7b23695ac..d9501a19c 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -124,4 +124,39 @@ describe ApplicationController, :type => :controller do expect(@controller.send(:after_sign_out_path_for, alice)).to eq(new_user_session_path) end end + + describe "#set_grammatical_gender" do + it "is called on page load" do + expect(@controller).to receive(:set_grammatical_gender) + get :index + end + + context "for inflected locales" do + before do + alice.language = :pl + alice.save + end + + it "returns nil for an empty gender" do + alice.person.profile.gender = "" + alice.person.profile.save + get :index + expect(assigns[:grammatical_gender]).to be_nil + end + + it "returns nil for an unrecognized gender" do + alice.person.profile.gender = "robot" + alice.person.profile.save + get :index + expect(assigns[:grammatical_gender]).to be_nil + end + + it "sets the correct grammatical gender" do + alice.person.profile.gender = "ona" + alice.person.profile.save + get :index + expect(assigns[:grammatical_gender]).to eq(:f) + end + end + end end