-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from senid231/517-fix-outgoing-registrations-1-9
fix outgoing registrations 1.9 #517
- Loading branch information
Showing
12 changed files
with
142 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryGirl.define do | ||
factory :outgoing_registration, class: RealtimeData::OutgoingRegistration do | ||
trait :filled do | ||
sequence(:id, 1_000) | ||
domain 'qwe.asd.com' | ||
user 'user_name' | ||
state 'some_state' | ||
auth_user 'auth.user' | ||
display_name 'display.name' | ||
contact 'some.contact' | ||
proxy '' | ||
expires { 5.minutes.from_now.utc.to_s(:db) } | ||
expires_left '5 minutes' | ||
last_error_code '' | ||
last_error_initiator '' | ||
last_error_reason '' | ||
last_request_time { Time.now.utc.to_s(:db) } | ||
last_succ_reg_time { Time.now.utc.to_s(:db) } | ||
attempt 1 | ||
max_attempts 5 | ||
retry_delay 2 | ||
end | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
spec/features/realtime_data/active_calls/index_active_calls_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Index Active Calls', type: :feature do | ||
include_context :login_as_admin | ||
|
||
let!(:node) { FactoryGirl.create(:node) } | ||
let(:record_attributes) { FactoryGirl.attributes_for(:active_call, :filled) } | ||
before do | ||
stub_jrpc_request('show.calls', node.rpc_endpoint).and_return([record_attributes.stringify_keys]) | ||
visit active_calls_path(q: { node_id_eq: node.id }) | ||
end | ||
|
||
it 'has record' do | ||
expect(page).to have_css('.col-duration', text: record_attributes[:duration].to_i) | ||
expect(page).to_not have_css('flash-warning') | ||
expect(page).to_not have_css('flash-error') | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
spec/features/realtime_data/incoming_resgistrations/index_incoming_registrations_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Index Incoming Registrations', type: :feature do | ||
include_context :login_as_admin | ||
|
||
let!(:node) { FactoryGirl.create(:node) } | ||
let(:record_attributes) { FactoryGirl.attributes_for(:incoming_registration, :filled) } | ||
before do | ||
stub_jrpc_request('show.aors', node.rpc_endpoint).and_return([record_attributes.stringify_keys]) | ||
allow(Node).to receive(:all).and_return([node]) | ||
visit incoming_registrations_path | ||
end | ||
|
||
it 'has record' do | ||
expect(page).to have_css('.col-path', text: record_attributes[:path]) | ||
expect(page).to_not have_css('flash-warning') | ||
expect(page).to_not have_css('flash-error') | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
spec/features/realtime_data/outgoing_resgistrations/index_outgoing_registrations_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Index Outgoing Registrations', type: :feature do | ||
include_context :login_as_admin | ||
|
||
let!(:node) { FactoryGirl.create(:node) } | ||
let(:record_attributes) { FactoryGirl.attributes_for(:outgoing_registration, :filled) } | ||
before do | ||
stub_jrpc_request('show.registrations', node.rpc_endpoint).and_return([record_attributes.stringify_keys]) | ||
visit outgoing_registrations_path(q: { node_id_eq: node.id }) | ||
end | ||
|
||
it 'has record' do | ||
expect(page).to have_css('.col-id', text: record_attributes[:id]) | ||
expect(page).to_not have_css('flash-warning') | ||
expect(page).to_not have_css('flash-error') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.shared_examples :test_index_table_exist do | ||
RSpec.shared_examples :test_index_table_exist do |id_css = '.resource_id_link'| | ||
it 'has record' do | ||
expect(page).to have_css('.resource_id_link', text: @item.id) | ||
expect(page).to have_css(id_css, text: @item.id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
module JRPCMockHelper | ||
# DSL allows stub JRPC in test environment. | ||
# Example: | ||
# | ||
# let!(:node) { FactoryGirl.create(:node) } | ||
# before do | ||
# stub_jrpc_request(:registrations, node.rpc_endpoint).with(123).and_return({ bar: 'baz' }) | ||
# end | ||
# | ||
# it 'calls correctly' do | ||
# expect(node.api.registration(123)).to match({ bar: 'baz' }) | ||
# end | ||
|
||
class StubHelper | ||
def initialize(stub:, ctx:, meth:) | ||
@stub = stub | ||
@ctx = ctx | ||
@meth = meth | ||
end | ||
|
||
def with(*params) | ||
stub_with_params(params) | ||
end | ||
|
||
def and_return(*args) | ||
stub_with_params([]).and_return(*args) | ||
end | ||
|
||
private | ||
|
||
def stub_with_params(params) | ||
@ctx.expect(@stub).to @ctx.receive(:perform_request).with(@meth, params: params).once | ||
end | ||
end | ||
|
||
def stub_jrpc_request(meth, uri, options = nil) | ||
options ||= hash_including(namespace: 'yeti.') | ||
jrpc_tcp_stub = instance_double(::JRPC::TcpClient, closed?: false, close: nil) | ||
expect(::JRPC::TcpClient).to receive(:new).with(uri, options).and_return(jrpc_tcp_stub) | ||
StubHelper.new(stub: jrpc_tcp_stub, ctx: self, meth: meth) | ||
end | ||
end |