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')
|
||||
end
|
||||
|
||||
flash[:notice] = I18n.t('registrar_added')
|
||||
flash[:notice] = t('.created')
|
||||
redirect_to [:admin, @registrar]
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash.now[:alert] = I18n.t('failed_to_add_registrar')
|
||||
flash.now[:alert] = t('.not_created')
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
@ -35,10 +35,10 @@ class Admin::RegistrarsController < AdminController
|
|||
|
||||
def update
|
||||
if @registrar.update(registrar_params)
|
||||
flash[:notice] = I18n.t('registrar_updated')
|
||||
flash[:notice] = t('.updated')
|
||||
redirect_to [:admin, @registrar]
|
||||
else
|
||||
flash.now[:alert] = I18n.t('failed_to_update_registrar')
|
||||
flash.now[:alert] = t('.not_updated')
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
.col-md-8
|
||||
.panel.panel-default
|
||||
.panel-heading.clearfix
|
||||
.pull-left= t(:misc)
|
||||
.pull-left= t('.misc')
|
||||
.panel-body
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
|
@ -91,4 +91,4 @@
|
|||
%hr
|
||||
.row
|
||||
.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
|
||||
= 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)
|
||||
|
||||
.row
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
en:
|
||||
admin:
|
||||
registrars:
|
||||
index:
|
||||
new_btn: New registrar
|
||||
|
||||
show:
|
||||
new_api_use_btn: New API user
|
||||
active: Active
|
||||
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'
|
||||
|
||||
new_registrar: 'New registrar'
|
||||
registrar_added: 'Registrar added!'
|
||||
failed_to_add_registrar: 'Failed to add registrar'
|
||||
registrar_details: 'Registrar details'
|
||||
vat_no: 'VAT no'
|
||||
edit_registrar: 'Edit registrar'
|
||||
back_to_registrar: 'Back to registrar'
|
||||
registrar_updated: 'Registrar updated'
|
||||
failed_to_update_registrar: 'Failed to update registrar'
|
||||
registrar_deleted: 'Registrar deleted'
|
||||
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