Skip to content

Add spec for trim_name method in CustomOrgLink model #6407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions spec/models/custom_org_link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
it { is_expected.to validate_length_of(:text).is_at_most described_class::TEXT_MAX_LENGTH }
it { is_expected.to validate_inclusion_of(:active).in_array [true, false] }

describe "#trim_name" do
let(:casa_org) { create(:casa_org) }

context "when text is present" do
it "trims leading and trailing whitespace from text" do
custom_link = build(:custom_org_link, casa_org: casa_org, text: " Example Text ")
custom_link.save
expect(custom_link.text).to eq("Example Text")
end
end
end

describe "url validation - only allow http or https schemes" do
it { is_expected.to allow_value("http://example.com").for(:url) }
it { is_expected.to allow_value("https://example.com").for(:url) }
Expand Down