Skip to content

Commit

Permalink
fix RoutingGroupDuplication at 1.7 branch (#410)
Browse files Browse the repository at this point in the history
* fix RoutingGroupDuplication. refs #408
  • Loading branch information
dmitry-sinina authored Dec 1, 2018
1 parent c686fda commit 2164e94
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/admin/routing/routing_group_duplicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

act_as_clone_helper_for RoutingGroup

permit_params :id, :name

controller do
# Redirects to index page instead of rendering updated resource
def create
Expand Down
40 changes: 40 additions & 0 deletions spec/features/routing_groups/copy_routing_group_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

describe 'Copy Routing group action', type: :feature do
include_context :login_as_admin

context 'success' do

let!(:routing_group) do
create(:routing_group).reload # after_save
end

let(:new_name) { routing_group.name + '_copy' }

before { visit routing_group_path(routing_group.id) }

before do
click_link('Copy', exact_text: true)
within '#new_routing_group' do
fill_in('routing_group_name', with: new_name)
end
end

subject do
find('input[type=submit]').click
find('h3', text: 'Routing Group Details') # wait page reload
end

it 'creates new Routing group with identical fields, except name' do
subject
expect(routing_group.dialpeers.count).to eq(0)
expect(RoutingGroup.count).to eq(2)
expect(RoutingGroup.last).to have_attributes(
name: new_name
)
end


end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper'

describe 'Copy Routing group with dialpeers action', type: :feature do
include_context :login_as_admin


let!(:routing_group) do
create(:routing_group)
end

before do
create_list(:dialpeer, 2, routing_group: routing_group)
end

let(:new_name) { routing_group.name + '_copy' }

before { visit routing_group_path(routing_group.id) }

before do
click_link('Copy with dialpeers', exact_text: true)
within '#new_routing_routing_group_duplicator' do
fill_in('Name', with: new_name)
find('input[type=submit]').click
end
#find('h2', text: 'Dialpeers') # wait page load
end


it 'creates new Routing group with duplicated Dialpeers' do
expect(page).to have_css('.flash_notice', text: 'Routing group duplicator was successfully created.')

expect(routing_group.reload.dialpeers.count).to eq(2)
expect(RoutingGroup.count).to eq(2)
expect(RoutingGroup.last.dialpeers.count).to eq(2)
end



end

0 comments on commit 2164e94

Please sign in to comment.