Skip to content

Commit 6e0e850

Browse files
committed
update tests
1 parent 6cc1bd9 commit 6e0e850

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

spec/models/feedback_reporters/abuse_reporter_spec.rb

+16-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,23 @@
7272
end
7373
end
7474

75-
context "if the report does not have an URL" do
76-
it "returns a hash containing 'Unknown URL'" do
77-
allow(subject).to receive(:url).and_return("")
75+
context "if the report has an empty referer" do
76+
before do
77+
allow(subject).to receive(:referer).and_return("")
78+
end
79+
80+
it "returns a hash containing a blank string for referer" do
81+
expect(subject.report_attributes.dig("cf", "cf_ticket_url")).to eq("")
82+
end
83+
end
84+
85+
context "if the reporter has a very long referer" do
86+
before do
87+
allow(subject).to receive(:referer).and_return("a" * 2081)
88+
end
7889

79-
expect(subject.report_attributes.fetch("cf").fetch("cf_ticket_url")).to eq("Unknown URL")
90+
it "truncates the referer to 2080 characters" do
91+
expect(subject.report_attributes.dig("cf", "cf_ticket_url").length).to eq(2080)
8092
end
8193
end
8294

spec/models/feedback_reporters/support_reporter_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@
120120
end
121121

122122
it "returns a hash containing a blank string for referer" do
123-
expect(subject.report_attributes.dig("cf", "cf_ticket_url")).to eq("Unknown URL")
123+
expect(subject.report_attributes.dig("cf", "cf_ticket_url")).to eq("")
124124
end
125125
end
126126

127127
context "if the reporter has a very long referer" do
128128
before do
129-
allow(subject).to receive(:referer).and_return("a" * 256)
129+
allow(subject).to receive(:referer).and_return("a" * 2081)
130130
end
131131

132132
it "truncates the referer to 2080 characters" do

0 commit comments

Comments
 (0)