diff --git a/config/locales/en.yml b/config/locales/en.yml index 797d97177..adc329141 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -225,6 +225,9 @@ en: state: 'State / Province' deposit: amount: 'Amount' + white_ip: + ipv4: 'IPv4' + ipv6: 'IPv6' errors: messages: @@ -560,8 +563,6 @@ en: code: 'Code' nameservers: 'Nameservers' hostname: 'Hostname' - ipv4: 'IPv4' - ipv6: 'IPv6' dnskeys: 'DNS Keys' flag: 'Flag' protocol: 'Protocol' diff --git a/db/schema.rb b/db/schema.rb index b6637648f..c3f85aabe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150519102521) do +ActiveRecord::Schema.define(version: 20150519140853) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/spec/features/admin/api_user_spec.rb b/spec/features/admin/api_user_spec.rb index 36ba2a767..f37adc2b6 100644 --- a/spec/features/admin/api_user_spec.rb +++ b/spec/features/admin/api_user_spec.rb @@ -15,14 +15,14 @@ feature 'Api users', type: :feature do it 'should redirect to login path' do visit admin_api_user_url(@api_user) - + current_path.should == '/admin/login' end end context 'as logged in user' do - it 'should show index of contacts' do + it 'should show index of api users' do sign_in @user visit admin_api_users_url diff --git a/spec/features/admin/white_ip_spec.rb b/spec/features/admin/white_ip_spec.rb new file mode 100644 index 000000000..fb84b3d30 --- /dev/null +++ b/spec/features/admin/white_ip_spec.rb @@ -0,0 +1,63 @@ +require 'rails_helper' + +feature 'Api users', type: :feature do + before :all do + @user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') + @registrar = Fabricate(:registrar) + end + + context 'as unknown user' do + it 'should redirect to login path' do + visit new_admin_registrar_white_ip_url(@registrar) + + current_path.should == '/admin/login' + end + end + + context 'as logged in user' do + before { sign_in @user } + + it 'should add new white ip to registrar' do + visit admin_registrar_url(@registrar) + + page.should_not have_text('192.168.1.1') + + click_link 'Create new white IP' + + fill_in 'IPv4', with: '192.168.1.1' + fill_in 'IPv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329' + select 'REPP', from: 'Interface' + click_button 'Save' + + page.should have_text('Record created') + page.should have_text('White IP') + page.should have_link(@registrar.to_s) + page.should have_text('192.168.1.1') + page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329') + page.should have_text('REPP') + + click_link @registrar.to_s + + current_path.should == "/admin/registrars/#{@registrar.id}" + page.should have_text('192.168.1.1') + page.should have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329') + page.should have_text('REPP') + end + + it 'should not add invalid ip to registrar' do + visit new_admin_registrar_white_ip_url(@registrar) + + click_button 'Save' + page.should have_text('IPv4 or IPv6 must be present') + page.should have_text('Failed to create record') + + fill_in 'IPv4', with: 'bla' + fill_in 'IPv6', with: 'bla' + + click_button 'Save' + + page.should have_text('IPv4 is invalid') + page.should have_text('IPv6 is invalid') + end + end +end