Skip to content

Instantly share code, notes, and snippets.

protected
def render_optional_error_file(status_code)
status = interpret_status(status_code)
render :template => "/errors/#{status[0,3]}.html.erb", :status => status, :layout => 'application.html.erb'
end
before :update do
self.status_changed = true if attribute_dirty?(:status)
end
after :update do
if status_changed
monster_type.update_time_average
self.status_changed = false
end
end
Feature: Creating client account
As team member
I want to create client account
So additional account information can be provided after visiting specified link
Scenario: Invalid email address provided
Given I am logged in as team member
When I go to clients index page
And I fill in "Email" field with "invalid_email" in "New client" form
And I click "Create" button
Given 'account with "$email" email does not exist' do |email|
account = Account.where(:email => email).first
account.delete unless account.nil?
end
Given 'I am not logged in' do
visit "/logout"
end
When 'I go to registration form' do
module Padrino
module Admin
module Helpers
module AuthenticationHelpers
private
def login_from_session
Account.find(session[options.session_id]) if session[options.session_id]
end
end
end
Feature: Creating client account
As team member
I want to create client account
So additional account information can be provided after visiting specified link
Scenario: Invalid email address provided
Given I am logged in as team member
When I go to clients index page
And I fill in "Email" field with "invalid_email" in "Invite client" fieldset
And I click "Invite" button
Given 'account with "$email" email and password of "$password" exist' do |email, password|
Given "account with \"#{ email }\" email does not exist"
Account.create(:email => email, :password => password, :password_confirmation => password)
end
Given 'inactive account with "$email" email exist' do |email|
Given "account with \"#{ email }\" email and password of \"secret\" exist"
account = Account.where(:email => email).first
account.is_active = false
account.save
Compito.helpers do
def absolute_url_for(*names)
path = url_for(*names)
scheme = request.scheme
if (scheme == 'http' && request.port == 80 ||
scheme == 'https' && request.port == 443)
port = ""
else
port = ":#{request.port}"
end
module Cucumber
module Web
module URLs
def url_for(*names)
Capybara.app.url_for(*names)
end
alias_method :url, :url_for
def absolute_url_for(*names)
"http://www.example.com" + Capybara.app.url_for(*names)
Feature: Viewing client index
As a team member
I want to see client index
Scenario: No client accounts exist
Given I am logged in as team member
And no active client accounts exist
When I go to clients index page
Then I should see "No active client accounts exist right now." message