Skip to content

Commit

Permalink
Modify tests so that they are valid whether ENABLE_HTTPS is yes or not
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Jul 22, 2012
1 parent 880183e commit 2b27a36
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 4 additions & 0 deletions test/acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module AcceptanceHelper

OmniAuth.config.test_mode = true

if ENV["ENABLE_HTTPS"] == "yes"
Capybara.app_host = 'https://www.example.com'
end

def app
RstatUs::Application
end
Expand Down
16 changes: 13 additions & 3 deletions test/acceptance/feeds_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

it "redirects to the username's atom feed with the right case" do
u = Fabricate(:user)
url = "http://www.example.com/feeds/#{u.feed.id}.atom"
visit "/users/#{u.username.upcase}/feed"
assert_equal url, page.current_url
current_url.must_match(/\/feeds\/#{u.feed.id}.atom$/)
end

it "404s if that username doesnt exist" do
Expand All @@ -24,6 +23,10 @@
end

get "/feeds/#{f.id}.atom"
if last_response.status == 301
follow_redirect!
end

atom = Nokogiri.XML(last_response.body)
entries = atom.xpath("//xmlns:entry")

Expand All @@ -35,7 +38,14 @@
later = Fabricate(:update, :feed => f, :created_at => 1.day.ago)
earlier = Fabricate(:update, :feed => f, :created_at => 2.weeks.ago)

get "/feeds/#{f.id}.atom", {}, "HTTP_IF_MODIFIED_SINCE" => 3.days.ago.httpdate
if ENV["ENABLE_HTTPS"] == "yes"
url = "https://www.example.com/feeds/#{f.id}.atom"
else
url = "http://www.example.com/feeds/#{f.id}.atom"
end

get url, {}, "HTTP_IF_MODIFIED_SINCE" => 3.days.ago.httpdate

atom = Nokogiri.XML(last_response.body)
entries = atom.xpath("//xmlns:entry")

Expand Down
3 changes: 1 addition & 2 deletions test/acceptance/profile_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

it "redirects to the username's profile with the right case" do
u = Fabricate(:user)
url = "http://www.example.com/users/#{u.username}"
visit "/users/#{u.username.upcase}"
assert_equal url, page.current_url
current_url.must_match(/\/users\/#{u.username}$/)
end

it "allows viewing of profiles when username contains a dot" do
Expand Down
4 changes: 4 additions & 0 deletions test/acceptance/salmon_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
it "404s if the request body does not contain a magic envelope" do
feed = Fabricate(:feed)
post "/feeds/#{feed.id}/salmon", "<?xml version='1.0' encoding='UTF-8'?><bogus-xml />"
if last_response.status == 301
follow_redirect!
end

last_response.status.must_equal(404)
end
end
6 changes: 6 additions & 0 deletions test/acceptance/webfinger_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@

it "404s if that user doesnt exist" do
get "/users/acct:[email protected]/xrd.xml"
if last_response.status == 301
follow_redirect!
end
last_response.status.must_equal(404)
end

it "renders the user's xrd" do
@user = Fabricate(:user)
param = "acct:#{@user.username}@#{@user.author.domain}"
get "/users/#{param}/xrd.xml"
if last_response.status == 301
follow_redirect!
end

xml = Nokogiri.XML(last_response.body)
subject = xml.xpath("//xmlns:Subject").first.content
Expand Down

0 comments on commit 2b27a36

Please sign in to comment.