lotus-controller 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +127 -0
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.md +259 -15
- data/lib/lotus/action.rb +20 -0
- data/lib/lotus/action/callbacks.rb +20 -2
- data/lib/lotus/action/configurable.rb +48 -0
- data/lib/lotus/action/cookie_jar.rb +29 -5
- data/lib/lotus/action/exposable.rb +12 -5
- data/lib/lotus/action/mime.rb +215 -32
- data/lib/lotus/action/params.rb +21 -4
- data/lib/lotus/action/rack.rb +81 -0
- data/lib/lotus/action/redirect.rb +6 -1
- data/lib/lotus/action/session.rb +1 -0
- data/lib/lotus/action/throwable.rb +37 -36
- data/lib/lotus/controller.rb +216 -17
- data/lib/lotus/controller/configuration.rb +510 -0
- data/lib/lotus/controller/dsl.rb +6 -4
- data/lib/lotus/controller/version.rb +1 -1
- data/lib/lotus/http/status.rb +5 -62
- data/lib/rack-patch.rb +4 -2
- data/lotus-controller.gemspec +3 -3
- metadata +26 -56
- data/.gitignore +0 -10
- data/.travis.yml +0 -5
- data/.yardopts +0 -4
- data/Gemfile +0 -15
- data/Rakefile +0 -17
- data/test/action/callbacks_test.rb +0 -99
- data/test/action/params_test.rb +0 -29
- data/test/action_test.rb +0 -31
- data/test/controller_test.rb +0 -24
- data/test/cookies_test.rb +0 -36
- data/test/fixtures.rb +0 -501
- data/test/integration/mime_type_test.rb +0 -175
- data/test/integration/routing_test.rb +0 -141
- data/test/integration/sessions_test.rb +0 -63
- data/test/redirect_test.rb +0 -20
- data/test/session_test.rb +0 -19
- data/test/test_helper.rb +0 -24
- data/test/throw_test.rb +0 -93
- data/test/version_test.rb +0 -7
data/test/throw_test.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
describe Lotus::Action do
|
4
|
-
describe '.handle_exception' do
|
5
|
-
it 'handle an exception with the given status' do
|
6
|
-
response = HandledExceptionAction.new.call({})
|
7
|
-
|
8
|
-
response[0].must_equal 404
|
9
|
-
end
|
10
|
-
|
11
|
-
it "returns a 500 if an action isn't handled" do
|
12
|
-
response = UnhandledExceptionAction.new.call({})
|
13
|
-
|
14
|
-
response[0].must_equal 500
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'with global handled exceptions' do
|
18
|
-
before do
|
19
|
-
class DomainLogicException < StandardError
|
20
|
-
end
|
21
|
-
|
22
|
-
Lotus::Controller.handled_exceptions = {DomainLogicException => 400}
|
23
|
-
|
24
|
-
class GlobalHandledExceptionAction
|
25
|
-
include Lotus::Action
|
26
|
-
|
27
|
-
def call(params)
|
28
|
-
raise DomainLogicException.new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
after do
|
34
|
-
Object.send(:remove_const, :DomainLogicException)
|
35
|
-
Object.send(:remove_const, :GlobalHandledExceptionAction)
|
36
|
-
|
37
|
-
Lotus::Controller.handled_exceptions = {}
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'handles raised exception' do
|
41
|
-
response = GlobalHandledExceptionAction.new.call({})
|
42
|
-
|
43
|
-
response[0].must_equal 400
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#throw' do
|
49
|
-
HTTP_TEST_STATUSES.each do |code, body|
|
50
|
-
it "throws an HTTP status code: #{ code }" do
|
51
|
-
response = ThrowCodeAction.new.call({ status: code })
|
52
|
-
|
53
|
-
response[0].must_equal code
|
54
|
-
response[2].must_equal [body]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'throws the code as it is, when not recognized' do
|
59
|
-
response = ThrowCodeAction.new.call({ status: 2131231 })
|
60
|
-
|
61
|
-
response[0].must_equal 500
|
62
|
-
response[2].must_equal ['Internal Server Error']
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'stops execution of before filters (method)' do
|
66
|
-
response = ThrowBeforeMethodAction.new.call({})
|
67
|
-
|
68
|
-
response[0].must_equal 401
|
69
|
-
response[2].must_equal ['Unauthorized']
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'stops execution of before filters (block)' do
|
73
|
-
response = ThrowBeforeBlockAction.new.call({})
|
74
|
-
|
75
|
-
response[0].must_equal 401
|
76
|
-
response[2].must_equal ['Unauthorized']
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'stops execution of after filters (method)' do
|
80
|
-
response = ThrowAfterMethodAction.new.call({})
|
81
|
-
|
82
|
-
response[0].must_equal 408
|
83
|
-
response[2].must_equal ['Request Timeout']
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'stops execution of after filters (block)' do
|
87
|
-
response = ThrowAfterBlockAction.new.call({})
|
88
|
-
|
89
|
-
response[0].must_equal 408
|
90
|
-
response[2].must_equal ['Request Timeout']
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|