Skip to content
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

remove to_curl functionality #1205 #1210

Merged
merged 1 commit into from Jul 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions app/models/notice.rb
Expand Up @@ -87,17 +87,6 @@ def host
"N/A"
end

def to_curl
return "N/A" if url.blank?
headers = %w(Accept Accept-Encoding Accept-Language Cookie Referer User-Agent).each_with_object([]) do |name, h|
if (value = env_vars["HTTP_#{name.underscore.upcase}"])
h << "-H '#{name}: #{value}'"
end
end

"curl -X #{env_vars['REQUEST_METHOD'] || 'GET'} #{headers.join(' ')} #{url}"
end

def env_vars
vars = request['cgi-data']
vars.is_a?(Hash) ? vars : {}
Expand Down
3 changes: 0 additions & 3 deletions app/views/notices/_summary.html.haml
Expand Up @@ -10,9 +10,6 @@
%tr
%th= t('.url')
%td.nowrap= link_to notice.request['url'], notice.request['url']
%tr
%th &nbsp;
%td= notice.to_curl
%tr
%th= t('.where')
%td= notice.where
Expand Down
22 changes: 0 additions & 22 deletions spec/models/notice_spec.rb
Expand Up @@ -65,28 +65,6 @@
end
end

describe "to_curl" do
let(:notice) { Fabricate.build(:notice, request: request) }

context "when it has a request url" do
let(:request) { { 'url' => "http://example.com/resource/12", 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } }

it 'has a curl representation' do
cmd = notice.to_curl
expect(cmd).to eq("curl -X GET -H 'User-Agent: Mozilla/5.0' http://example.com/resource/12")
end
end

context "when it has not a request url" do
let(:request) { { 'cgi-data' => { 'HTTP_USER_AGENT' => 'Mozilla/5.0' } } }

it 'has a curl representation' do
cmd = notice.to_curl
expect(cmd).to eq "N/A"
end
end
end

describe "user agent" do
it "should be parsed and human-readable" do
notice = Fabricate.build(:notice, request: { 'cgi-data' => {
Expand Down