Add application controller specs for grammatical gender

This commit is contained in:
Steffen van Bergerem 2016-09-03 11:14:06 +02:00 committed by Dennis Schubert
parent 08794bc47b
commit 89b51dddf9
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E

View file

@ -124,4 +124,39 @@ describe ApplicationController, :type => :controller do
expect(@controller.send(:after_sign_out_path_for, alice)).to eq(new_user_session_path) expect(@controller.send(:after_sign_out_path_for, alice)).to eq(new_user_session_path)
end end
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 end