From 8e24bab64428f7578fff29ed02c008c16113da81 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Tue, 5 Apr 2022 13:49:38 +0100 Subject: [PATCH] Add helper test --- spec/helpers/user_helper_spec.rb | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 spec/helpers/user_helper_spec.rb diff --git a/spec/helpers/user_helper_spec.rb b/spec/helpers/user_helper_spec.rb new file mode 100644 index 000000000..6386ddd4f --- /dev/null +++ b/spec/helpers/user_helper_spec.rb @@ -0,0 +1,38 @@ +require "rails_helper" + +RSpec.describe UserHelper do + let(:current_user) { FactoryBot.create(:user, :data_coordinator) } + let(:user) { FactoryBot.create(:user, :data_coordinator) } + + describe "aliased_user_edit" do + context "when the current logged in user is the same as the user being viewed" do + let(:user) { current_user } + + it "returns the edit account path" do + expect(aliased_user_edit(user, current_user)).to eq(edit_account_path) + end + end + + context "when the current logged in user is not the same as the user being viewed" do + it "returns the edit user path" do + expect(aliased_user_edit(user, current_user)).to eq(edit_user_path(user)) + end + end + end + + describe "pronoun" do + context "when the current logged in user is the same as the user being viewed" do + let(:user) { current_user } + + it "returns 'you'" do + expect(pronoun(user, current_user)).to eq("you") + end + end + + context "when the current logged in user is not the same as the user being viewed" do + it "returns 'they'" do + expect(pronoun(user, current_user)).to eq("they") + end + end + end +end