-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
176 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
require File.join(File.dirname(__FILE__), '../test_helper') | ||
require 'evil/application' | ||
|
||
class FrontendTest < Test::Unit::TestCase | ||
include Sinatra::Test | ||
|
||
context 'running the evil application' do | ||
setup do | ||
@app = Evil::Application | ||
end | ||
|
||
|
||
context 'GET a template page' do | ||
setup do | ||
@template = Factory.create(:template) | ||
@app.reload! | ||
get @template.route | ||
end | ||
|
||
should 'be successful' do | ||
assert_equal 200, response.status | ||
end | ||
|
||
should 'render with text/html as default content_type' do | ||
assert_match /text\/html/, response.headers['Content-Type'] | ||
assert_match /utf-8/, response.headers['Content-Type'] | ||
end | ||
|
||
should 'set a Cache-Control header from the template\'s ttl' do | ||
assert_match /max-age=#{@template.ttl}/, response.headers['Cache-Control'] | ||
end | ||
end | ||
|
||
context 'GET a template page with another content type set' do | ||
setup do | ||
@template = Factory.create(:template, :content_type => 'application/xml') | ||
@app.reload! | ||
get @template.route | ||
end | ||
|
||
should 'be successful' do | ||
assert_equal 200, response.status | ||
end | ||
|
||
should 'render with text/html as default content_type' do | ||
assert_match /application\/xml/, response.headers['Content-Type'] | ||
assert_match /utf-8/, response.headers['Content-Type'] | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require File.join(File.dirname(__FILE__), '../test_helper') | ||
require 'evil/application' | ||
|
||
class OpenidTest < Test::Unit::TestCase | ||
include Sinatra::Test | ||
|
||
context 'running the evil application' do | ||
setup do | ||
@app = Evil::Application | ||
end | ||
|
||
context 'while not logged in' do | ||
|
||
context 'GET /admin' do | ||
setup do | ||
get '/admin' | ||
end | ||
|
||
should 'not be authorized' do | ||
assert_equal 401, response.status | ||
assert_match /openid_url/, response.body | ||
end | ||
end | ||
end | ||
|
||
|
||
context 'while logged in' do | ||
setup do | ||
Factory.create(:whitelist) | ||
@env = { 'rack.session' => { :identity_url => 'www.example.com' } } | ||
end | ||
|
||
context 'GET /admin' do | ||
setup do | ||
get '/admin', {}, @env | ||
end | ||
|
||
should 'be successful' do | ||
assert response.ok? | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require File.join(File.dirname(__FILE__), '../test_helper') | ||
require 'evil/application' | ||
|
||
class PluginConfigTest < Test::Unit::TestCase | ||
include Sinatra::Test | ||
|
||
context 'running the evil application' do | ||
setup do | ||
@app = Evil::Application | ||
end | ||
|
||
|
||
context 'while logged in' do | ||
setup do | ||
Factory.create(:whitelist) | ||
@env = { 'rack.session' => { :identity_url => 'www.example.com' } } | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require File.join(File.dirname(__FILE__), '../test_helper') | ||
require 'evil/application' | ||
|
||
class TemplateTest < Test::Unit::TestCase | ||
include Sinatra::Test | ||
|
||
context 'running the evil application' do | ||
setup do | ||
@app = Evil::Application | ||
end | ||
|
||
context 'while logged in' do | ||
setup do | ||
Factory.create(:whitelist) | ||
@env = { 'rack.session' => { :identity_url => 'www.example.com' } } | ||
end | ||
|
||
context 'GET /admin/templates/id with existing template' do | ||
setup do | ||
@template = Factory.create(:template) | ||
get "/admin/templates/#{@template.id}", {}, @env | ||
end | ||
|
||
should 'be successful' do | ||
assert_equal 200, response.status | ||
end | ||
end | ||
|
||
context 'GET /admin/templates/nothinghere with non-existing template' do | ||
setup do | ||
get '/admin/templates/nothinghere', {}, @env | ||
end | ||
|
||
should 'be not found' do | ||
assert_equal 404, response.status | ||
end | ||
end | ||
|
||
context 'GET /admin/templates/new' do | ||
setup do | ||
get '/admin/templates/new', {}, @env | ||
end | ||
|
||
should 'be successful' do | ||
assert_equal 200, response.status | ||
end | ||
end | ||
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