-
Notifications
You must be signed in to change notification settings - Fork 2
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
7 changed files
with
106 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SECRET=abad1dea # < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; | ||
RACK_ENV=test # staging|production | ||
DATABASE_URL=sqlite:///tmp/test.sqlite # DATABASE_URL=postgres://[user]:[password]@[host]:[port]/yogurt_development |
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,57 @@ | ||
require './test/test_helper' | ||
|
||
class CommunitiesTest < MiniTest::Test | ||
include Rack::Test::Methods | ||
|
||
def app | ||
Yogurt.app | ||
end | ||
|
||
def test_index_shows_created_community | ||
community_name = "A nice community" | ||
community = Community.create name: community_name | ||
|
||
get "/communities" | ||
|
||
assert last_response.ok? | ||
assert last_response.body.include? community_name | ||
end | ||
|
||
def test_edit_existing_community | ||
community_name = "A nice community" | ||
community = Community.create name: community_name | ||
|
||
get "/communities/#{community.id}/edit" | ||
|
||
assert last_response.ok? | ||
assert last_response.body.include? community_name | ||
end | ||
|
||
def test_edit_absent_community | ||
get "/communities/999/edit" | ||
|
||
refute last_response.ok? | ||
assert last_response.status == 404 | ||
end | ||
|
||
def test_delete_existing_community | ||
community_name = "A nice community" | ||
community = Community.create name: community_name | ||
|
||
id = community.id | ||
|
||
delete "/communities/#{id}" | ||
|
||
follow_redirect! | ||
|
||
assert Community[id].nil? | ||
assert_equal last_request.path, "/communities" | ||
end | ||
|
||
def test_delete_absent_community | ||
delete "/communities/999" | ||
|
||
refute last_response.ok? | ||
assert last_response.status == 404 | ||
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,18 @@ | ||
require "minitest/autorun" | ||
require "rack/test" | ||
require "pry" | ||
|
||
require './models.rb' | ||
require './yogurt.rb' | ||
|
||
class MiniTest::Test | ||
alias_method :_original_run, :run | ||
|
||
def run(*args, &block) | ||
result = nil | ||
Sequel::Model.db.transaction(:rollback => :always, :auto_savepoint=>true) do | ||
result = _original_run(*args, &block) | ||
end | ||
result | ||
end | ||
end |