Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/models/billing/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@
class Billing::Service < ApplicationRecord
self.table_name = 'billing.services'

before_update :prevent_modification_if_terminated
before_destroy :prevent_modification_if_terminated

STATE_ID_ACTIVE = 10
STATE_ID_SUSPENDED = 20
STATE_ID_TERMINATED = 30

STATES = {
STATE_ID_ACTIVE => 'Active',
STATE_ID_SUSPENDED => 'Suspended'
STATE_ID_SUSPENDED => 'Suspended',
STATE_ID_TERMINATED => 'Terminated'
}.freeze

RENEW_PERIOD_ID_DAY = 10
Expand Down Expand Up @@ -117,6 +122,13 @@ def build_provisioning_object

private

def prevent_modification_if_terminated
if state_id == STATE_ID_TERMINATED
errors.add(:base, "Modifications are not allowed for terminated records")
throw(:abort)
end
end

def provisioning_object_after_create
build_provisioning_object.after_create
end
Expand Down
17 changes: 9 additions & 8 deletions spec/features/cdr/cdr_exports/new_cdr_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@

# filters
fill_in 'Customer external id eq', with: '1231'
fill_in_chosen 'Customer id eq', with: "#{customer.name} | #{customer.id}"
fill_in_chosen 'Customer id eq', with: "#{customer.name} | #{customer.id}", ajax: true
fill_in 'Customer acc external id eq', with: '1232'
fill_in_chosen 'Customer acc id eq', with: "#{account.name} | #{account.id}"
fill_in_chosen 'Customer acc id eq', with: "#{account.name} | #{account.id}", ajax: true
fill_in 'Vendor external id eq', with: '1233'
fill_in_chosen 'Vendor id eq', with: "#{vendor.name} | #{vendor.id}"
fill_in_chosen 'Vendor id eq', with: "#{vendor.name} | #{vendor.id}", ajax: true
fill_in 'Vendor acc external id eq', with: '1234'
fill_in_chosen 'Vendor acc id eq', with: "#{vendor_acc.name} | #{vendor_acc.id}"
fill_in_chosen 'Vendor acc id eq', with: "#{vendor_acc.name} | #{vendor_acc.id}", ajax: true
fill_in 'Customer auth external id eq', with: '1235'
scroll_to(find('label', text: 'Customer auth id eq'))
fill_in_chosen 'Customer auth id eq', with: "#{customer_auth.name} | #{customer_auth.id}"
fill_in 'Src prefix in contains', with: 'src_prefix_in_test'
fill_in 'Src prefix in eq', with: 'src_prefix_in_test'
Expand All @@ -112,8 +113,8 @@
fill_in 'Dst prefix routing eq', with: 'dst_prefix_routing_test'
fill_in 'Dst prefix out contains', with: 'dst_prefix_out_test'
fill_in 'Dst prefix out eq', with: 'dst_prefix_out_test'
fill_in_chosen 'Src country id eq', with: countries.first.name
fill_in_chosen 'Dst country id eq', with: countries.last.name
fill_in_chosen 'Src country id eq', with: countries.first.name, ajax: true
fill_in_chosen 'Dst country id eq', with: countries.last.name, ajax: true
fill_in 'Routing tag ids include', with: 2
fill_in 'Routing tag ids exclude', with: 25
fill_in_chosen 'Routing tag ids empty', with: 'No'
Expand All @@ -133,8 +134,8 @@
fill_in 'Customer auth external type eq', with: 'term'
fill_in 'Customer auth external type not eq', with: 'em'
fill_in_chosen 'Customer auth external id in', with: customer_auth.name, multiple: true, ajax: true
fill_in_chosen 'Src country iso in', with: countries.first.name, multiple: true
fill_in_chosen 'Dst country iso in', with: countries.first.name, multiple: true
fill_in_chosen 'Src country iso in', with: countries.first.name, multiple: true, ajax: true
fill_in_chosen 'Dst country iso in', with: countries.first.name, multiple: true, ajax: true

# all allowed filters must be filled in this test.
CdrExport::FiltersModel.attribute_types.each_key do |filter_key|
Expand Down
10 changes: 5 additions & 5 deletions spec/support/helpers/chosen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def chosen_container_selector(label, disabled: nil, exact: false)
def chosen_select(chosen_selector, search:, multiple: false, chosen_node: nil, ajax: false, exact: false)
chosen_node ||= page.find(chosen_selector)
if multiple
chosen_node.find('.search-field').click
chosen_node.find('.search-field').trigger('click')
else
chosen_node.click
chosen_node.trigger('click')
end
expect(page).to have_selector('ul.chosen-results li.active-result') unless ajax
if multiple
Expand All @@ -57,14 +57,14 @@ def chosen_select(chosen_selector, search:, multiple: false, chosen_node: nil, a
end
within(chosen_node) do
expect(page).to have_selector('ul.chosen-results li.active-result') if ajax
find('.active-result', text: search, exact_text: exact).click
find('.active-result', text: search, exact_text: exact).trigger('click')
end
end

def chosen_pick(css_selector, text:, chosen_node: nil, exact: false)
chosen_node ||= page.find(css_selector)
chosen_node.click
find('ul.chosen-results li.active-result', text: text, exact_text: exact).click
chosen_node.trigger('click')
find('ul.chosen-results li.active-result', text: text, exact_text: exact).trigger('click')
end

def chosen_deselect_value(label, exact: false)
Expand Down
Loading