Skip to content

Commit

Permalink
Bugfix: use API endpoints for Unleash 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
rarruda committed Jul 3, 2018
1 parent de4e951 commit 6fe2b30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/unleash/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def refresh_backup_file!
end

def fetch_toggles_url
self.url + '/features'
self.url + '/client/features'
end

def client_metrics_url
Expand Down
22 changes: 22 additions & 0 deletions spec/unleash/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,36 @@
# expect(config.validate!).to raise_error(ArgumentError)
expect(config.backup_file).to_not be_nil
end

it "should by default be invalid" do
config = Unleash::Configuration.new()
expect{ config.validate! }.to raise_error(ArgumentError)
end

it "should be valid with the mandatory arguments set" do
config = Unleash::Configuration.new(app_name: 'rspec_test', url: 'http://testurl/')
expect{ config.validate! }.not_to raise_error
end

it "support yield for setting the configuration" do
Unleash.configure do |config|
config.url = 'http://test-url/'
config.app_name = 'my-test-app'
end
expect{ Unleash.configuration.validate! }.not_to raise_error
expect(Unleash.configuration.url).to eq('http://test-url/')
expect(Unleash.configuration.app_name).to eq('my-test-app')
expect(Unleash.configuration.fetch_toggles_url).to eq('http://test-url//client/features')
end

it "should build the correct unleash endpoints from the base url" do
config = Unleash::Configuration.new(url: 'https://testurl/api', app_name: 'test-app')
expect(config.url).to eq('https://testurl/api')
expect(config.fetch_toggles_url).to eq('https://testurl/api/client/features')
expect(config.client_metrics_url).to eq('https://testurl/api/client/metrics')
expect(config.client_register_url).to eq('https://testurl/api/client/register')
end

end

end

0 comments on commit 6fe2b30

Please sign in to comment.