-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from jclusso/lookup_via_url
Add ability to lookup via URL
- Loading branch information
Showing
12 changed files
with
166 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class RedirectController < ApplicationController | ||
|
||
def create | ||
if params[:domain_name].present? | ||
query = Query.new(params.permit(:server, :type, :domain_name)) | ||
query.type ||= 'A' | ||
query.server ||= 'Cloudflare' | ||
query.session_id = session.id.to_s | ||
|
||
if query.valid? | ||
query.do_dns_lookup! | ||
query.save | ||
|
||
redirect_to query_path(query) | ||
else | ||
redirect_to root_path | ||
end | ||
else | ||
redirect_to root_path | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require "test_helper" | ||
|
||
class RedirectControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@domain = Faker::Internet.unique.domain_name | ||
end | ||
|
||
test "should create query with server, type, and domain" do | ||
get "/google/mx/#{@domain}" | ||
|
||
assert_redirected_to query_path(new_query) | ||
assert_equal 'Google', new_query.server | ||
assert_equal 'MX', new_query.type | ||
assert_equal @domain, new_query.domain | ||
end | ||
|
||
test "should create query with type and domain" do | ||
get "/mx/#{@domain}" | ||
|
||
assert_redirected_to query_path(new_query) | ||
assert_equal 'Cloudflare', new_query.server | ||
assert_equal 'MX', new_query.type | ||
assert_equal @domain, new_query.domain | ||
end | ||
|
||
test "should create query with domain" do | ||
get "/#{@domain}" | ||
|
||
assert_redirected_to query_path(new_query) | ||
assert_equal 'Cloudflare', new_query.server | ||
assert_equal 'A', new_query.type | ||
assert_equal @domain, new_query.domain | ||
end | ||
|
||
private | ||
|
||
def new_query | ||
@new_query ||= Query.find_by(domain: @domain) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters