Commit 26c36652f69947a95750348867b3adb27aaa7294
Committed by
Paulo Meireles
1 parent
67ed0208
Exists in
master
and in
28 other branches
Get service address from configuration file
Showing
3 changed files
with
15 additions
and
2 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/port.rb
@@ -11,7 +11,11 @@ class Kalibro::Client::Port | @@ -11,7 +11,11 @@ class Kalibro::Client::Port | ||
11 | end | 11 | end |
12 | 12 | ||
13 | def service_address | 13 | def service_address |
14 | - @service_address ||= 'http://valinhos.ime.usp.br:50688/KalibroService/' | 14 | + if @service_address.nil? |
15 | + service_file = "#{RAILS_ROOT}/plugins/mezuro/SERVICE" | ||
16 | + File.open(service_file).each_line{ | line | @service_address = line } | ||
17 | + end | ||
18 | + @service_address | ||
15 | end | 19 | end |
16 | 20 | ||
17 | def request(action, request_body = nil) | 21 | def request(action, request_body = nil) |
plugins/mezuro/test/unit/kalibro/client/port_test.rb
@@ -2,12 +2,13 @@ require "test_helper" | @@ -2,12 +2,13 @@ require "test_helper" | ||
2 | class PortTest < Test::Unit::TestCase | 2 | class PortTest < Test::Unit::TestCase |
3 | 3 | ||
4 | def setup | 4 | def setup |
5 | - @default_address = 'http://localhost:8080/KalibroService/' | ||
6 | @client = mock | 5 | @client = mock |
6 | + set_default_address | ||
7 | Savon::Client.expects(:new).with("#{@default_address}PortTestEndpoint/?wsdl").returns(@client) | 7 | Savon::Client.expects(:new).with("#{@default_address}PortTestEndpoint/?wsdl").returns(@client) |
8 | @port = Kalibro::Client::Port.new('PortTest') | 8 | @port = Kalibro::Client::Port.new('PortTest') |
9 | end | 9 | end |
10 | 10 | ||
11 | + | ||
11 | should 'get default address' do | 12 | should 'get default address' do |
12 | assert_equal @default_address, @port.service_address | 13 | assert_equal @default_address, @port.service_address |
13 | end | 14 | end |
@@ -22,4 +23,11 @@ class PortTest < Test::Unit::TestCase | @@ -22,4 +23,11 @@ class PortTest < Test::Unit::TestCase | ||
22 | assert_equal response_body, @port.request(:port_test_action) | 23 | assert_equal response_body, @port.request(:port_test_action) |
23 | end | 24 | end |
24 | 25 | ||
26 | + private | ||
27 | + | ||
28 | + def set_default_address | ||
29 | + service_file = "#{RAILS_ROOT}/plugins/mezuro/SERVICE" | ||
30 | + File.open(service_file).each_line{ | line | @default_address = line } | ||
31 | + end | ||
32 | + | ||
25 | end | 33 | end |
26 | \ No newline at end of file | 34 | \ No newline at end of file |