mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
parent
6f907e11b5
commit
b4b715f405
7 changed files with 61 additions and 11 deletions
|
@ -23,10 +23,10 @@ class Admin::RegistrarsController < AdminController
|
||||||
@registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
|
@registrar.accounts.create!(account_type: Account::CASH, currency: 'EUR')
|
||||||
end
|
end
|
||||||
|
|
||||||
flash[:notice] = I18n.t('registrar_added')
|
flash[:notice] = t('.created')
|
||||||
redirect_to [:admin, @registrar]
|
redirect_to [:admin, @registrar]
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
flash.now[:alert] = t('.not_created')
|
||||||
render 'new'
|
render 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -35,10 +35,10 @@ class Admin::RegistrarsController < AdminController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @registrar.update(registrar_params)
|
if @registrar.update(registrar_params)
|
||||||
flash[:notice] = I18n.t('registrar_updated')
|
flash[:notice] = t('.updated')
|
||||||
redirect_to [:admin, @registrar]
|
redirect_to [:admin, @registrar]
|
||||||
else
|
else
|
||||||
flash.now[:alert] = I18n.t('failed_to_update_registrar')
|
flash.now[:alert] = t('.not_updated')
|
||||||
render 'edit'
|
render 'edit'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
.col-md-8
|
.col-md-8
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading.clearfix
|
.panel-heading.clearfix
|
||||||
.pull-left= t(:misc)
|
.pull-left= t('.misc')
|
||||||
.panel-body
|
.panel-body
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-4.control-label
|
.col-md-4.control-label
|
||||||
|
@ -91,4 +91,4 @@
|
||||||
%hr
|
%hr
|
||||||
.row
|
.row
|
||||||
.col-md-8.text-right
|
.col-md-8.text-right
|
||||||
= button_tag(t(:save), class: 'btn btn-primary')
|
= button_tag(t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
- content_for :actions do
|
- content_for :actions do
|
||||||
= link_to(t(:new), new_admin_registrar_path, class: 'btn btn-primary')
|
= link_to(t('.new_btn'), new_admin_registrar_path, class: 'btn btn-primary')
|
||||||
= render 'shared/title', name: t(:registrars)
|
= render 'shared/title', name: t(:registrars)
|
||||||
|
|
||||||
.row
|
.row
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
en:
|
en:
|
||||||
admin:
|
admin:
|
||||||
registrars:
|
registrars:
|
||||||
|
index:
|
||||||
|
new_btn: New registrar
|
||||||
|
|
||||||
show:
|
show:
|
||||||
new_api_use_btn: New API user
|
new_api_use_btn: New API user
|
||||||
active: Active
|
active: Active
|
||||||
api_users: API users
|
api_users: API users
|
||||||
|
|
||||||
|
create:
|
||||||
|
created: Registrar has been successfully created
|
||||||
|
not_created: Unable to create registrar
|
||||||
|
|
||||||
|
update:
|
||||||
|
updated: Registrar has been successfully updated
|
||||||
|
not_updated: Unable to update registrar
|
||||||
|
|
||||||
|
form:
|
||||||
|
misc: Miscellaneous
|
||||||
|
create_btn: Create registrar
|
||||||
|
update_btn: Update registrar
|
||||||
|
|
|
@ -394,14 +394,10 @@ en:
|
||||||
history: 'History'
|
history: 'History'
|
||||||
|
|
||||||
new_registrar: 'New registrar'
|
new_registrar: 'New registrar'
|
||||||
registrar_added: 'Registrar added!'
|
|
||||||
failed_to_add_registrar: 'Failed to add registrar'
|
|
||||||
registrar_details: 'Registrar details'
|
registrar_details: 'Registrar details'
|
||||||
vat_no: 'VAT no'
|
vat_no: 'VAT no'
|
||||||
edit_registrar: 'Edit registrar'
|
edit_registrar: 'Edit registrar'
|
||||||
back_to_registrar: 'Back to registrar'
|
back_to_registrar: 'Back to registrar'
|
||||||
registrar_updated: 'Registrar updated'
|
|
||||||
failed_to_update_registrar: 'Failed to update registrar'
|
|
||||||
registrar_deleted: 'Registrar deleted'
|
registrar_deleted: 'Registrar deleted'
|
||||||
failed_to_delete_registrar: 'Failed to delete registrar'
|
failed_to_delete_registrar: 'Failed to delete registrar'
|
||||||
|
|
||||||
|
|
20
spec/features/admin/registrars/create_spec.rb
Normal file
20
spec/features/admin/registrars/create_spec.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.feature 'New registrar' do
|
||||||
|
background do
|
||||||
|
sign_in_to_admin_area
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates registrar' do
|
||||||
|
visit admin_registrars_url
|
||||||
|
click_link_or_button 'New registrar'
|
||||||
|
|
||||||
|
fill_in 'registrar[name]', with: 'test'
|
||||||
|
fill_in 'registrar[reg_no]', with: '1234567'
|
||||||
|
fill_in 'registrar[email]', with: 'test@test.com'
|
||||||
|
fill_in 'registrar[code]', with: 'test'
|
||||||
|
click_link_or_button 'Create registrar'
|
||||||
|
|
||||||
|
expect(page).to have_text('Registrar has been successfully created')
|
||||||
|
end
|
||||||
|
end
|
18
spec/features/admin/registrars/edit_spec.rb
Normal file
18
spec/features/admin/registrars/edit_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.feature 'Edit registrar' do
|
||||||
|
given!(:registrar) { create(:registrar_with_unlimited_balance) }
|
||||||
|
|
||||||
|
background do
|
||||||
|
sign_in_to_admin_area
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'updates registrar' do
|
||||||
|
visit admin_registrar_url(registrar)
|
||||||
|
click_link_or_button 'Edit'
|
||||||
|
|
||||||
|
click_link_or_button 'Update registrar'
|
||||||
|
|
||||||
|
expect(page).to have_text('Registrar has been successfully updated')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue