ballast 1.5.3 → 1.6.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 +9 -3
- data/Gemfile +1 -1
- data/ballast.gemspec +2 -3
- data/doc/Ballast.html +1 -1
- data/doc/Ballast/Concerns.html +1 -1
- data/doc/Ballast/Concerns/Ajax.html +103 -20
- data/doc/Ballast/Concerns/Common.html +173 -42
- data/doc/Ballast/Concerns/ErrorsHandling.html +1 -1
- data/doc/Ballast/Concerns/View.html +1 -1
- data/doc/Ballast/Configuration.html +2 -2
- data/doc/Ballast/Context.html +1 -1
- data/doc/Ballast/Errors.html +1 -1
- data/doc/Ballast/Errors/BaseError.html +1 -1
- data/doc/Ballast/Errors/InvalidDomain.html +1 -1
- data/doc/Ballast/Errors/PerformError.html +1 -1
- data/doc/Ballast/Errors/ValidationError.html +1 -1
- data/doc/Ballast/Middlewares.html +1 -1
- data/doc/Ballast/Middlewares/DefaultHost.html +1 -1
- data/doc/Ballast/Operation.html +1 -1
- data/doc/Ballast/OperationsChain.html +18 -6
- data/doc/Ballast/RequestDomainMatcher.html +1 -1
- data/doc/Ballast/Version.html +3 -3
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +22 -16
- data/doc/top-level-namespace.html +1 -1
- data/lib/ballast/concerns/ajax.rb +13 -5
- data/lib/ballast/concerns/common.rb +11 -1
- data/lib/ballast/configuration.rb +1 -14
- data/lib/ballast/operations_chain.rb +8 -1
- data/lib/ballast/version.rb +2 -2
- data/spec/ballast/concerns/ajax_spec.rb +12 -0
- data/spec/ballast/concerns/common_spec.rb +12 -0
- data/spec/ballast/operations_chain_spec.rb +43 -15
- metadata +6 -20
@@ -32,7 +32,14 @@ module Ballast
|
|
32
32
|
def initialize(operations, context)
|
33
33
|
@context = context
|
34
34
|
@operations = operations.ensure_array
|
35
|
-
setup
|
36
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
# Returns the operations to perform.
|
39
|
+
#
|
40
|
+
# @return [Array] An array of operations to perform.
|
41
|
+
def interactors
|
42
|
+
@operations
|
43
|
+
end
|
37
44
|
end
|
38
45
|
end
|
data/lib/ballast/version.rb
CHANGED
@@ -113,6 +113,18 @@ describe Ballast::Concerns::Ajax do
|
|
113
113
|
"Access-Control-Max-Age" => "31557600"
|
114
114
|
})
|
115
115
|
end
|
116
|
+
|
117
|
+
it "should append custom headers values" do
|
118
|
+
subject.allow_cors(allow_origin: "ORIGIN", allow_methods: [:first, :second], allow_headers: "_", max_age: 1.day, allow_credentials: true)
|
119
|
+
|
120
|
+
expect(subject.headers).to eq({
|
121
|
+
"Access-Control-Allow-Origin" => "ORIGIN",
|
122
|
+
"Access-Control-Allow-Methods" => "FIRST, SECOND",
|
123
|
+
"Access-Control-Allow-Headers" => "_",
|
124
|
+
"Access-Control-Max-Age" => "86400",
|
125
|
+
"Access-Control-Allow-Credentials" => "true"
|
126
|
+
})
|
127
|
+
end
|
116
128
|
end
|
117
129
|
|
118
130
|
describe "#disallow_robots" do
|
@@ -57,6 +57,18 @@ describe Ballast::Concerns::Common do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe "#perform_operations_chain" do
|
61
|
+
it "should perform the requested operation chain and memoize it" do
|
62
|
+
expect(Ballast::OperationsChain).to receive(:perform).with("OWNER", [:a, :b], a: 1, b: 2).and_return("OPERATION 1")
|
63
|
+
expect(Ballast::OperationsChain).to receive(:perform).with(subject, [:c, :d], c: 3, d: 4).and_return("OPERATION 2")
|
64
|
+
|
65
|
+
subject.perform_operations_chain([:a, :b], "OWNER", a: 1, b: 2)
|
66
|
+
expect(subject.instance_variable_get(:@operation)).to eq("OPERATION 1")
|
67
|
+
subject.perform_operations_chain([:c, :d], c: 3, d: 4)
|
68
|
+
expect(subject.instance_variable_get(:@operation)).to eq("OPERATION 2")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
60
72
|
describe "#format_short_duration" do
|
61
73
|
it "should format a date" do
|
62
74
|
now = DateTime.civil(2013, 12, 9, 15, 6, 00)
|
@@ -7,27 +7,55 @@ require "spec_helper"
|
|
7
7
|
|
8
8
|
describe Ballast::OperationsChain do
|
9
9
|
describe ".perform" do
|
10
|
-
|
11
|
-
|
10
|
+
class SuccessOperation < Ballast::Operation
|
11
|
+
def perform
|
12
|
+
response[:result] ||= 0
|
13
|
+
response[:result] += 1
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Ballast::OperationsChain.perform(context, [:A, :B, :C])
|
17
|
+
class FailureOperation < Ballast::Operation
|
18
|
+
def perform
|
19
|
+
fail!
|
20
|
+
end
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
Ballast::OperationsChain.perform(nil, [:A, :B, :C], context: context)
|
23
|
+
class FinalOperation < Ballast::Operation
|
24
|
+
def perform
|
25
|
+
response[:result] = "#{response[:result]}F"
|
26
|
+
end
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
describe ".perform" do
|
30
|
+
before(:each) do
|
31
|
+
expect_any_instance_of(Ballast::OperationsChain).to receive(:perform)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should initialize with the set of operations and the first argument as context" do
|
35
|
+
context = Ballast::Context.new
|
36
|
+
expect(Ballast::Context).not_to receive(:build)
|
37
|
+
expect(Ballast::OperationsChain).to receive(:new).with([:A, :B, :C], context).and_call_original
|
38
|
+
Ballast::OperationsChain.perform(context, [:A, :B, :C])
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should use the provided owner and context" do
|
42
|
+
context = Ballast::Context.new
|
43
|
+
expect(Ballast::Context).not_to receive(:build)
|
44
|
+
expect(Ballast::OperationsChain).to receive(:new).with([:A, :B, :C], context).and_call_original
|
45
|
+
Ballast::OperationsChain.perform(nil, [:A, :B, :C], context: context)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should created the context on the fly if needed" do
|
49
|
+
expect(Ballast::Context).to receive(:build).with("A", {a: 1})
|
50
|
+
Ballast::OperationsChain.perform("A", [:A, :B, :C], params: {a: 1})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#perform" do
|
55
|
+
it "should execute the operations unless they fail" do
|
56
|
+
expect(Ballast::OperationsChain.perform(nil, [SuccessOperation, FinalOperation]).response[:result]).to eq("1F")
|
57
|
+
expect(Ballast::OperationsChain.perform(nil, [SuccessOperation, FailureOperation, FinalOperation]).response[:result].to_s).not_to match(/F$/)
|
58
|
+
end
|
31
59
|
end
|
32
60
|
end
|
33
61
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ballast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -52,34 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 2.5.3
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: lazier
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.3.10
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.3.10
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: brauser
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - "~>"
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.2.
|
61
|
+
version: 3.2.5
|
76
62
|
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.2.
|
68
|
+
version: 3.2.5
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: interactor
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|