Add some feature tests

This commit is contained in:
Martin Lensment 2014-09-16 11:49:49 +03:00
parent a72560c3d3
commit 4c4c65d431
7 changed files with 70 additions and 8 deletions

View file

@ -3,13 +3,10 @@ class Admin::NameserversController < ApplicationController
before_action :set_nameserver, only: [:edit, :update, :destroy]
def new
@domain = Domain.find(params[:domain_id])
@nameserver = @domain.nameservers.build
end
def create
@domain = Domain.find(params[:domain_id])
unless @domain.can_add_nameserver?
@nameserver = @domain.nameservers.build(nameserver_params)
flash.now[:alert] = I18n.t('shared.failed_to_add_nameserver')
@ -28,7 +25,6 @@ class Admin::NameserversController < ApplicationController
end
def edit
@domain = Domain.find(params[:domain_id])
@nameserver = Nameserver.find(params[:id])
end

View file

@ -1,5 +1,5 @@
- panel_class = @domain.errors.messages[:nameservers] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
#nameservers.panel{class: panel_class}
.panel-heading.clearfix
.pull-left
= t('shared.nameservers')

View file

@ -1,5 +1,5 @@
- panel_class = @domain.errors.messages[:domain_statuses] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
#domain_statuses.panel{class: panel_class}
.panel-heading.clearfix
.pull-left
= t('shared.statuses')

View file

@ -1,5 +1,5 @@
- panel_class = @domain.errors.messages[:tech_contacts] ? 'panel-danger' : 'panel-default'
.panel{class: panel_class}
#tech_contacts.panel{class: panel_class}
.panel-heading.clearfix
.pull-left
= t('shared.tech_contacts')

View file

@ -11,7 +11,7 @@
.col-md-12
.form-group.has-feedback
.form-group.has-feedback
= label_tag :tech_contact
= label_tag :domain_contact, t('shared.tech_contact')
= text_field_tag(:domain_contact, params[:domain_contact], class: 'form-control js-contact-typeahead', placeholder: t('shared.contact_code'), autocomplete: 'off')
%span.glyphicon.glyphicon-ok.form-control-feedback.js-typeahead-ok.hidden
%span.glyphicon.glyphicon-remove.form-control-feedback.js-typeahead-remove

View file

@ -224,3 +224,4 @@ en:
failed_to_update_status: 'Failed to update status!'
status_deleted: 'Status deleted!'
failed_to_delete_status: 'Failed to delete status!'
tech_contact: 'Tech contact'

View file

@ -56,4 +56,69 @@ feature 'Domain management', type: :feature do
expect(page).to have_text(c.phone)
expect(page).to have_text('Nameservers count must be between 1-13')
end
scenario 'User adds nameserver to domain' do
d = Domain.first
visit admin_domain_path(d)
within('#nameservers') { click_on 'Add' }
fill_in('Hostname', with: 'ns1.example.ee')
fill_in('Ipv4', with: '192.168.1.1')
fill_in('Ipv6', with: 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
click_on 'Save'
expect(page).to have_text('Nameserver added!')
within('#nameservers') do
expect(page).to have_link('ns1.example.ee')
expect(page).to have_text('192.168.1.1')
expect(page).to have_text('FE80:0000:0000:0000:0202:B3FF:FE1E:8329')
end
end
scenario 'User adds status to domain' do
d = Domain.first
visit admin_domain_path(d)
within('#domain_statuses') { click_on 'Add' }
fill_in('Description', with: 'All is well.')
click_on 'Save'
expect(page).to have_text('Status added!')
within('#domain_statuses') do
expect(page).to have_text('ok')
expect(page).to have_text('All is well.')
end
end
scenario 'User adds technical contact', js: true do
d = Domain.first
visit admin_domain_path(d)
within('#tech_contacts') { click_on 'Add' }
c = Contact.last
fill_in('Tech contact', with: c.code, fill_options: { blur: false })
# TODO: Wait for poltergeist to support blur option, then uncomment these lines:
# expect(page).to have_text(c.code)
# click_on(c.code)
# expect(find_field('Tech contact').value).to eq(c.code)
# temporary solution:
page.execute_script("$('#contact_id').val('#{c.id}')")
click_on 'Save'
expect(page).to have_text('Contact added!')
within('#tech_contacts') do
expect(page).to have_link(c.name)
expect(page).to have_text(c.email)
end
end
end