Skip to content

Commit

Permalink
Update Habitat to 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcsmith committed Aug 28, 2018
1 parent 0e1b6ca commit 7ed55e4
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 40 deletions.
6 changes: 3 additions & 3 deletions UPGRADE_NOTES.md
Expand Up @@ -140,7 +140,7 @@ You can probably copy this as-is, but if you have made customizations to your
`config/server.cr` then you'll need to customize this:

```crystal
Lucky::Server.configure do
Lucky::Server.configure do |settings|
if Lucky::Env.production?
settings.secret_key_base = secret_key_from_env
settings.host = "0.0.0.0"
Expand Down Expand Up @@ -174,7 +174,7 @@ port: 5000

- Update `config/database.cr`

Put this inside of the `LuckyRecord::Repo.configure do` block:
Put this inside of the `LuckyRecord::Repo.configure do |settings|` block:

```
# In development and test, raise an error if you forget to preload associations
Expand Down Expand Up @@ -322,7 +322,7 @@ Then run `shards update`

```crystal
# Add to config/route_helper.cr
Lucky::RouteHelper.configure do
Lucky::RouteHelper.configure do |settings|
if Lucky::Env.production?
# The APP_DOMAIN is something like https://myapp.com
settings.domain = ENV.fetch("APP_DOMAIN")
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Expand Up @@ -34,7 +34,7 @@ dependencies:
version: ~> 0.6
habitat:
github: luckyframework/habitat
version: ~> 0.3.0
version: ~> 0.4.0
lucky_inflector:
github: luckyframework/lucky_inflector
version: ~> 0.1.1
Expand Down
5 changes: 3 additions & 2 deletions spec/lucky/action_spec.cr
Expand Up @@ -145,8 +145,9 @@ end

describe Lucky::Action do
it "has a url helper" do
Lucky::RouteHelper.configure { settings.base_uri = "example.com" }
Tests::Index.url.should eq "example.com/tests"
Lucky::RouteHelper.temp_config(base_uri: "example.com") do
Tests::Index.url.should eq "example.com/tests"
end
end

describe "routing" do
Expand Down
4 changes: 2 additions & 2 deletions spec/lucky/error_handling_spec.cr
Expand Up @@ -49,7 +49,7 @@ describe Lucky::ErrorHandler do
context "when configured to show debug output" do
it "prints debug output instead of calling the error action" do
begin
Lucky::ErrorHandler.configure do
Lucky::ErrorHandler.configure do |settings|
settings.show_debug_output = true
end

Expand All @@ -61,7 +61,7 @@ describe Lucky::ErrorHandler do
context.response.headers["Content-Type"].should eq("text/html")
context.response.status_code.should eq(500)
ensure
Lucky::ErrorHandler.configure do
Lucky::ErrorHandler.configure do |settings|
settings.show_debug_output = false
end
end
Expand Down
7 changes: 3 additions & 4 deletions spec/lucky/form_helpers_spec.cr
Expand Up @@ -87,10 +87,9 @@ describe Lucky::FormHelpers do
end

private def without_csrf_protection
Lucky::FormHelpers.configure { settings.include_csrf_tag = false }
yield
ensure
Lucky::FormHelpers.configure { settings.include_csrf_tag = true }
Lucky::FormHelpers.temp_config(include_csrf_tag: false) do
yield
end
end

private def view(context : HTTP::Server::Context = build_context)
Expand Down
8 changes: 4 additions & 4 deletions spec/lucky/route_helper_spec.cr
Expand Up @@ -3,11 +3,11 @@ require "../spec_helper"
describe Lucky::RouteHelper do
describe "url" do
it "returns the host + path" do
Lucky::RouteHelper.configure { settings.base_uri = "example.com" }
Lucky::RouteHelper.temp_config(base_uri: "example.com") do
route = Lucky::RouteHelper.new(:get, "/users")

route = Lucky::RouteHelper.new(:get, "/users")

route.url.should eq("example.com/users")
route.url.should eq("example.com/users")
end
end
end
end
10 changes: 2 additions & 8 deletions spec/lucky/static_file_handler_spec.cr
Expand Up @@ -4,8 +4,7 @@ include ContextHelper

describe Lucky::StaticFileHandler do
it "hides static files from logs" do
begin
Lucky::StaticFileHandler.configure { settings.hide_from_logs = true }
Lucky::StaticFileHandler.temp_config(hide_from_logs: true) do
context = build_context
context.hide_from_logs?.should be_false
called = false
Expand All @@ -14,14 +13,11 @@ describe Lucky::StaticFileHandler do

called.should be_true
context.hide_from_logs?.should be_true
ensure
Lucky::StaticFileHandler.configure { settings.hide_from_logs = true }
end
end

it "shows static files in logs" do
begin
Lucky::StaticFileHandler.configure { settings.hide_from_logs = false }
Lucky::StaticFileHandler.temp_config(hide_from_logs: false) do
context = build_context
context.hide_from_logs?.should be_false
called = false
Expand All @@ -30,8 +26,6 @@ describe Lucky::StaticFileHandler do

called.should be_true
context.hide_from_logs?.should be_false
ensure
Lucky::StaticFileHandler.configure { settings.hide_from_logs = true }
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/spec_helper.cr
Expand Up @@ -7,34 +7,34 @@ Spec.before_each do
ARGV.clear
end

Lucky::Session::Store.configure do
Lucky::Session::Store.configure do |settings|
settings.key = "test_app"
settings.secret = "super-secret"
end

Lucky::Server.configure do
Lucky::Server.configure do |settings|
settings.secret_key_base = "super-secret"
settings.host = "0.0.0.0"
settings.port = 8080
end

Lucky::RouteHelper.configure do
Lucky::RouteHelper.configure do |settings|
settings.base_uri = "luckyframework.org"
end

LuckyRecord::Repo.configure do
LuckyRecord::Repo.configure do |settings|
settings.url = "Not used yet"
end

Lucky::ErrorHandler.configure do
Lucky::ErrorHandler.configure do |settings|
settings.show_debug_output = false
end

Lucky::LogHandler.configure do
Lucky::LogHandler.configure do |settings|
settings.show_timestamps = false
end

Lucky::StaticFileHandler.configure do
Lucky::StaticFileHandler.configure do |settings|
settings.hide_from_logs = true
end

Expand Down
2 changes: 1 addition & 1 deletion src/lucky/force_ssl_handler.cr
Expand Up @@ -15,7 +15,7 @@
#
# ```
# # Usually in config/force_ssl_handler.cr
# Lucky::ForceSSLHandler.configure do
# Lucky::ForceSSLHandler.configure do |settings|
# settings.redirect_status = 303
# settings.enabled = false
# end
Expand Down
16 changes: 8 additions & 8 deletions src/server.cr
Expand Up @@ -2,11 +2,11 @@ require "./lucky"
require "./app/**"
require "colorize"

Lucky::Server.configure do
Lucky::Server.configure do |settings|
settings.secret_key_base = "super_secret"
end

Lucky::Session::Store.configure do
Lucky::Session::Store.configure do |settings|
settings.key = "test_app"
settings.secret = "super-secret"
end
Expand All @@ -18,27 +18,27 @@ server = HTTP::Server.new([
Lucky::RouteHandler.new,
])

Lucky::RouteHelper.configure do
Lucky::RouteHelper.configure do |settings|
settings.base_uri = "some_value"
end

LuckyRecord::Repo.configure do
LuckyRecord::Repo.configure do |settings|
settings.url = ""
end

Lucky::StaticFileHandler.configure do
Lucky::StaticFileHandler.configure do |settings|
settings.hide_from_logs = true
end

Lucky::ErrorHandler.configure do
Lucky::ErrorHandler.configure do |settings|
settings.show_debug_output = true
end

Lucky::LogHandler.configure do
Lucky::LogHandler.configure do |settings|
settings.show_timestamps = false
end

Lucky::Server.configure do
Lucky::Server.configure do |settings|
settings.host = "0.0.0.0"
settings.port = 8080
end
Expand Down

0 comments on commit 7ed55e4

Please sign in to comment.