Skip to content

Commit e23c5ce

Browse files
committed
url is used more
1 parent af81ae3 commit e23c5ce

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

app/controllers/abuse_reports_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def new
99
@abuse_report.email = reporter.email
1010
@abuse_report.username = reporter.login
1111
end
12-
@abuse_report.referer = params[:referer] || request.env["HTTP_REFERER"]
12+
@abuse_report.referer = params[:url] || request.env["HTTP_REFERER"]
1313
end
1414

1515
def create
@@ -32,7 +32,7 @@ def load_abuse_languages
3232

3333
def abuse_report_params
3434
params.require(:abuse_report).permit(
35-
:username, :email, :language, :summary, :referer, :comment
35+
:username, :email, :language, :summary, :url, :comment
3636
)
3737
end
3838
end

app/models/feedback_reporters/abuse_reporter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def custom_zoho_fields
1414
# To avoid issues where Zoho ticket creation silently fails, only grab the first
1515
# 2080 characters of the referer URL. That may miss some complex search queries,
1616
# but still keep enough to be useful most of the time.
17-
truncated_referer = referer.present? ? referer[0..2079] : ""
17+
truncated_referer = url.present? ? url[0..2079] : ""
1818
{
1919
"cf_ip" => ip_address.presence || "Unknown IP",
2020
"cf_ticket_url" => truncated_referer

app/models/feedback_reporters/support_reporter.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def custom_zoho_fields
1616
# To avoid issues where Zoho ticket creation silently fails, only grab the first
1717
# 2080 characters of the referer URL. That may miss some complex search queries,
1818
# but still keep enough to be useful most of the time.
19-
truncated_referer = referer.present? ? referer[0..2079] : ""
19+
truncated_referer = url.present? ? url[0..2079] : ""
2020
{
2121
"cf_archive_version" => site_revision.presence || "Unknown site revision",
2222
"cf_rollout" => rollout.presence || "Unknown",

features/step_definitions/support_steps.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
allow(ArchiveConfig).to receive(:PERMITTED_HOSTS).and_return([host])
1313
end
1414

15-
Then "a Zoho ticket should be created with referer {string}" do |referer|
15+
Then "a Zoho ticket should be created with url {string}" do |url|
1616
# rubocop:disable Lint/AmbiguousBlockAssociation
1717
expect(WebMock).to have_requested(:post, "https://desk.zoho.com/api/v1/tickets")
18-
.with { |req| JSON.parse(req.body)["cf"]["cf_ticket_url"] == referer }
18+
.with { |req| JSON.parse(req.body)["cf"]["cf_ticket_url"] == url }
1919
# rubocop:enable Lint/AmbiguousBlockAssociation
2020
end

spec/models/feedback_reporters/abuse_reporter_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
username: "Walrus",
1515
ip_address: "127.0.0.1",
16-
referer: "https://example.com/works/1"
16+
url: "https://example.com/works/1"
1717
}
1818
end
1919

@@ -72,22 +72,22 @@
7272
end
7373
end
7474

75-
context "if the report has an empty referer" do
75+
context "if the report has an empty URL" do
7676
before do
77-
allow(subject).to receive(:referer).and_return("")
77+
allow(subject).to receive(:url).and_return("")
7878
end
7979

80-
it "returns a hash containing a blank string for url" do
80+
it "returns a hash containing a blank string for URL" do
8181
expect(subject.report_attributes.dig("cf", "cf_ticket_url")).to eq("")
8282
end
8383
end
8484

85-
context "if the reporter has a very long referer" do
85+
context "if the reporter has a very long URL" do
8686
before do
87-
allow(subject).to receive(:referer).and_return("a" * 2081)
87+
allow(subject).to receive(:url).and_return("a" * 2081)
8888
end
8989

90-
it "truncates the referer to 2080 characters" do
90+
it "truncates the URL to 2080 characters" do
9191
expect(subject.report_attributes.dig("cf", "cf_ticket_url").length).to eq(2080)
9292
end
9393
end

spec/models/feedback_reporters/support_reporter_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
site_revision: "eternal_beta",
1717
rollout: "rollout_value",
1818
ip_address: "127.0.0.1",
19-
referer: "https://example.com/works/1",
19+
url: "https://example.com/works/1",
2020
site_skin: build(:skin, title: "Reversi", public: true)
2121
}
2222
end
@@ -114,22 +114,22 @@
114114
end
115115
end
116116

117-
context "if the report has an empty referer" do
117+
context "if the report has an empty URL" do
118118
before do
119-
allow(subject).to receive(:referer).and_return("")
119+
allow(subject).to receive(:url).and_return("")
120120
end
121121

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

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

132-
it "truncates the referer to 2080 characters" do
132+
it "truncates the URL to 2080 characters" do
133133
expect(subject.report_attributes.dig("cf", "cf_ticket_url").length).to eq(2080)
134134
end
135135
end

0 commit comments

Comments
 (0)