Merge branch 'master' into filter-datatables
This commit is contained in:
commit
7eb32bf1c3
33 changed files with 529 additions and 43 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,3 +15,4 @@
|
||||||
/log/*
|
/log/*
|
||||||
!/log/.keep
|
!/log/.keep
|
||||||
/tmp
|
/tmp
|
||||||
|
coverage/
|
||||||
|
|
14
.travis.yml
Normal file
14
.travis.yml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
language: ruby
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- RAILS_ENV=test bundle exec rspec spec
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
email:
|
||||||
|
recipients:
|
||||||
|
- tab@zeus.ugent.be
|
||||||
|
on_success: never
|
||||||
|
on_failure: change
|
||||||
|
slack:
|
||||||
|
secure: G2bPwlS5GR3EkCqdeeE5usS0k/JKEErShIED0M1+/IKhTf6Yn7r4S4KZARndIG6B2y4nZ5EF0ONbdqZkOTwj6QaPv+2NNqmh2CK9Q6BqEN/5fyx5zfVUjCJNRnXPVWuyhooYaKbaDO23KtwvsW0ZpFjS+pZzTZNEWI4UOo2ojIEW1jZfFHYJ0U/W6HX8j65VwWP0/I7od7XBs7UgNavndtJV8sQyRXCvlGfkkYe8MgxG/6QdCV9z46i+IbfPkvETMFIhrx0CpohV00TsVOmuPWpqbi86YV5EzdSWImdc3Dyei+SG6xSi3mfaocEjEvb3btHYBYRwCzBU+ObYLHmz7FdG3Vqzyhqf9c8hzuAAUduXYX9W1sEHi6nfwQqquuibXhptpyS/Np7wqSGhqdbdmTbgWpdAbTEwg9i9ZGgV+YpGhYMypA2yGA/7x+akoHJoKEL7qGsbncifjJlOqYoAVVVj67PFIszyDQiGBlMFddn233oqT+3odyiJGWLaXZY+7Ew1sE1BX5GpFxO71EwMZMxhm0FDtittpkK/uhX05d4DvPElxUmIHWEf5UMvQxjrqpSuYjXLM7xEVn2zktZ1Skk6X4wGU6bSV2Jy+JpzVvkVBXzTf9JMZSMbDKwypwcUjXBn+7/frv5QXkCJrKsRIPm8Ox69YNsDuNz/EWpcQsI=
|
9
Gemfile
9
Gemfile
|
@ -76,8 +76,17 @@ group :development do
|
||||||
gem 'capistrano-passenger'
|
gem 'capistrano-passenger'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem 'coveralls', require: false
|
||||||
|
end
|
||||||
|
|
||||||
group :production do
|
group :production do
|
||||||
gem 'mysql2', '~> 0.3.0'
|
gem 'mysql2', '~> 0.3.0'
|
||||||
end
|
end
|
||||||
|
|
||||||
gem 'high_voltage', '~> 2.4.0'
|
gem 'high_voltage', '~> 2.4.0'
|
||||||
|
|
||||||
|
gem 'simple_form'
|
||||||
|
|
||||||
|
# Errors on errbit
|
||||||
|
gem 'airbrake'
|
||||||
|
|
36
Gemfile.lock
36
Gemfile.lock
|
@ -36,6 +36,9 @@ GEM
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
thread_safe (~> 0.3, >= 0.3.4)
|
thread_safe (~> 0.3, >= 0.3.4)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
airbrake (4.3.1)
|
||||||
|
builder
|
||||||
|
multi_json
|
||||||
annotate (2.6.10)
|
annotate (2.6.10)
|
||||||
activerecord (>= 3.2, <= 4.3)
|
activerecord (>= 3.2, <= 4.3)
|
||||||
rake (~> 10.4)
|
rake (~> 10.4)
|
||||||
|
@ -69,6 +72,12 @@ GEM
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.9.1.1)
|
coffee-script-source (1.9.1.1)
|
||||||
colorize (0.7.7)
|
colorize (0.7.7)
|
||||||
|
coveralls (0.8.2)
|
||||||
|
json (~> 1.8)
|
||||||
|
rest-client (>= 1.6.8, < 2)
|
||||||
|
simplecov (~> 0.10.0)
|
||||||
|
term-ansicolor (~> 1.3)
|
||||||
|
thor (~> 0.19.1)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
devise (3.5.2)
|
devise (3.5.2)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
|
@ -78,6 +87,9 @@ GEM
|
||||||
thread_safe (~> 0.1)
|
thread_safe (~> 0.1)
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
|
docile (1.1.5)
|
||||||
|
domain_name (0.5.24)
|
||||||
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
execjs (2.6.0)
|
execjs (2.6.0)
|
||||||
factory_girl (4.5.0)
|
factory_girl (4.5.0)
|
||||||
|
@ -106,6 +118,8 @@ GEM
|
||||||
haml (~> 4.0.0)
|
haml (~> 4.0.0)
|
||||||
nokogiri (~> 1.6.0)
|
nokogiri (~> 1.6.0)
|
||||||
ruby_parser (~> 3.5)
|
ruby_parser (~> 3.5)
|
||||||
|
http-cookie (1.0.2)
|
||||||
|
domain_name (~> 0.5)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
jbuilder (2.3.1)
|
jbuilder (2.3.1)
|
||||||
activesupport (>= 3.0.0, < 5)
|
activesupport (>= 3.0.0, < 5)
|
||||||
|
@ -135,6 +149,7 @@ GEM
|
||||||
net-scp (1.2.1)
|
net-scp (1.2.1)
|
||||||
net-ssh (>= 2.6.5)
|
net-ssh (>= 2.6.5)
|
||||||
net-ssh (2.9.2)
|
net-ssh (2.9.2)
|
||||||
|
netrc (0.10.3)
|
||||||
nokogiri (1.6.6.2)
|
nokogiri (1.6.6.2)
|
||||||
mini_portile (~> 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
oauth2 (1.0.0)
|
oauth2 (1.0.0)
|
||||||
|
@ -183,6 +198,10 @@ GEM
|
||||||
rdoc (4.2.0)
|
rdoc (4.2.0)
|
||||||
responders (2.1.0)
|
responders (2.1.0)
|
||||||
railties (>= 4.2.0, < 5)
|
railties (>= 4.2.0, < 5)
|
||||||
|
rest-client (1.8.0)
|
||||||
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
|
mime-types (>= 1.16, < 3.0)
|
||||||
|
netrc (~> 0.7)
|
||||||
rspec-core (3.3.2)
|
rspec-core (3.3.2)
|
||||||
rspec-support (~> 3.3.0)
|
rspec-support (~> 3.3.0)
|
||||||
rspec-expectations (3.3.1)
|
rspec-expectations (3.3.1)
|
||||||
|
@ -215,6 +234,14 @@ GEM
|
||||||
select2-rails (3.5.9.3)
|
select2-rails (3.5.9.3)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
sexp_processor (4.6.0)
|
sexp_processor (4.6.0)
|
||||||
|
simple_form (3.1.1)
|
||||||
|
actionpack (~> 4.0)
|
||||||
|
activemodel (~> 4.0)
|
||||||
|
simplecov (0.10.0)
|
||||||
|
docile (~> 1.1.0)
|
||||||
|
json (~> 1.8)
|
||||||
|
simplecov-html (~> 0.10.0)
|
||||||
|
simplecov-html (0.10.0)
|
||||||
spring (1.3.6)
|
spring (1.3.6)
|
||||||
sprockets (3.3.4)
|
sprockets (3.3.4)
|
||||||
rack (~> 1.0)
|
rack (~> 1.0)
|
||||||
|
@ -227,9 +254,12 @@ GEM
|
||||||
colorize (>= 0.7.0)
|
colorize (>= 0.7.0)
|
||||||
net-scp (>= 1.1.2)
|
net-scp (>= 1.1.2)
|
||||||
net-ssh (>= 2.8.0)
|
net-ssh (>= 2.8.0)
|
||||||
|
term-ansicolor (1.3.2)
|
||||||
|
tins (~> 1.0)
|
||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tilt (2.0.1)
|
tilt (2.0.1)
|
||||||
|
tins (1.6.0)
|
||||||
turbolinks (2.5.3)
|
turbolinks (2.5.3)
|
||||||
coffee-rails
|
coffee-rails
|
||||||
tzinfo (1.2.2)
|
tzinfo (1.2.2)
|
||||||
|
@ -237,6 +267,9 @@ GEM
|
||||||
uglifier (2.7.2)
|
uglifier (2.7.2)
|
||||||
execjs (>= 0.3.0)
|
execjs (>= 0.3.0)
|
||||||
json (>= 1.8.0)
|
json (>= 1.8.0)
|
||||||
|
unf (0.1.4)
|
||||||
|
unf_ext
|
||||||
|
unf_ext (0.0.7.1)
|
||||||
warden (1.2.3)
|
warden (1.2.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
web-console (2.2.1)
|
web-console (2.2.1)
|
||||||
|
@ -249,6 +282,7 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
airbrake
|
||||||
annotate
|
annotate
|
||||||
byebug
|
byebug
|
||||||
cancancan
|
cancancan
|
||||||
|
@ -257,6 +291,7 @@ DEPENDENCIES
|
||||||
capistrano-rails (~> 1.1)
|
capistrano-rails (~> 1.1)
|
||||||
capistrano-rbenv
|
capistrano-rbenv
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
|
coveralls
|
||||||
devise
|
devise
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
faker
|
faker
|
||||||
|
@ -273,6 +308,7 @@ DEPENDENCIES
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
sdoc (~> 0.4.0)
|
sdoc (~> 0.4.0)
|
||||||
select2-rails
|
select2-rails
|
||||||
|
simple_form
|
||||||
spring
|
spring
|
||||||
sqlite3
|
sqlite3
|
||||||
turbolinks
|
turbolinks
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
# Tab
|
# [Tab](https://zeus.ugent.be/tab) [![Analytics](https://ga-beacon.appspot.com/UA-25444917-6/ZeusWPI/Tab/README.md?pixel)](https://github.com/igrigorik/ga-beacon) [![Code Climate](https://codeclimate.com/github/ZeusWPI/Tab/badges/gpa.svg)](https://codeclimate.com/github/ZeusWPI/Tab) [![Coverage Status](https://coveralls.io/repos/ZeusWPI/Tab/badge.svg?branch=master&service=github)](https://coveralls.io/github/ZeusWPI/Tab?branch=master) [![Build Status](https://travis-ci.org/ZeusWPI/Tab.png?branch=master)](https://travis-ci.org/ZeusWPI/Tab)
|
||||||
|
|
|
@ -16,3 +16,6 @@
|
||||||
*= require_self
|
*= require_self
|
||||||
*= require purecss
|
*= require purecss
|
||||||
*/
|
*/
|
||||||
|
body {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
|
22
app/assets/stylesheets/forms.css.scss
Normal file
22
app/assets/stylesheets/forms.css.scss
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
.error_panel {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
border-radius: 3px;
|
||||||
|
border: 1px solid #ebccd1;
|
||||||
|
.error_header {
|
||||||
|
.error_title {
|
||||||
|
font-size: 16px;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
padding: 10px 15px;
|
||||||
|
color: #a94442;
|
||||||
|
background-color: #f2dede;
|
||||||
|
}
|
||||||
|
.error_body {
|
||||||
|
padding: 15px;
|
||||||
|
ul {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,3 +7,39 @@
|
||||||
=require purecss/menus
|
=require purecss/menus
|
||||||
=require purecss/tables
|
=require purecss/tables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Alerts */
|
||||||
|
.pure-alert {
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
background: #ccc;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-alert label {
|
||||||
|
display: inline-block;
|
||||||
|
*display: inline;
|
||||||
|
/* IE7 inline-block hack */
|
||||||
|
*zoom: 1;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-alert {
|
||||||
|
background-color: rgb(209, 235, 238);
|
||||||
|
color: rgb(102, 131, 145);
|
||||||
|
}
|
||||||
|
.pure-alert-error {
|
||||||
|
background-color: #D13C38;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-alert-warning {
|
||||||
|
background-color: rgb(250, 191, 103);
|
||||||
|
color: rgb(151, 96, 13);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pure-alert-success {
|
||||||
|
background-color: rgb(83, 180, 79);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
|
@ -6,4 +6,18 @@ class ApplicationController < ActionController::Base
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
redirect_to root_url, alert: exception.message
|
redirect_to root_url, alert: exception.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authenticate_user_or_client!
|
||||||
|
current_user || current_client || head(:unauthorized)
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_client
|
||||||
|
@current_client ||= Client.find_by key: request.headers["X-API-KEY"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_ability
|
||||||
|
@current_ability ||=
|
||||||
|
current_client.try { |c| ClientAbility.new(c) } ||
|
||||||
|
Ability.new(current_user)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ module DataTable
|
||||||
def selection_to_json(user, selection)
|
def selection_to_json(user, selection)
|
||||||
{ data: selection.map { |transaction| {
|
{ data: selection.map { |transaction| {
|
||||||
amount: transaction.signed_amount_for(user),
|
amount: transaction.signed_amount_for(user),
|
||||||
origin: transaction.origin,
|
issuer: transaction.issuer.name,
|
||||||
message: transaction.message,
|
message: transaction.message,
|
||||||
peer: transaction.peer_of(user).try(:name),
|
peer: transaction.peer_of(user).try(:name),
|
||||||
time: transaction.created_at
|
time: transaction.created_at
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
class TransactionsController < ApplicationController
|
class TransactionsController < ApplicationController
|
||||||
|
load_and_authorize_resource
|
||||||
|
skip_before_filter :verify_authenticity_token, only: :create
|
||||||
|
|
||||||
|
before_action :authenticate_user!, except: :create
|
||||||
|
before_action :authenticate_user_or_client!, only: :create
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@transactions = Transaction.all
|
@transactions = Transaction.all
|
||||||
|
@ -9,18 +14,35 @@ class TransactionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@transaction = current_user.outgoing_transactions.build transaction_params.merge(origin: I18n.t('origin.created_by_user'))
|
@transaction = Transaction.new(transaction_params)
|
||||||
|
respond_to do |format|
|
||||||
|
format.html do
|
||||||
if @transaction.save
|
if @transaction.save
|
||||||
redirect_to current_user
|
flash[:success] = "Transaction created"
|
||||||
|
redirect_to new_transaction_path
|
||||||
else
|
else
|
||||||
render 'new'
|
render 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
format.json do
|
||||||
|
head(@transaction.save ? :created : :unprocessable_entity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def transaction_params
|
def transaction_params
|
||||||
params.require(:transaction).permit(:creditor_id, :amount, :message)
|
t = params.require(:transaction)
|
||||||
|
.permit(:debtor, :creditor, :message, :euros, :cents)
|
||||||
|
|
||||||
|
{
|
||||||
|
debtor: User.find_by(name: t[:debtor]) || User.zeus,
|
||||||
|
creditor: User.find_by(name: t[:creditor]) || User.zeus,
|
||||||
|
issuer: current_client || current_user,
|
||||||
|
amount: (t[:euros].to_f*100 + t[:cents].to_f).to_i,
|
||||||
|
message: t[:message]
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,12 +2,10 @@ class Ability
|
||||||
include CanCan::Ability
|
include CanCan::Ability
|
||||||
|
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
user ||= User.new # guest user (not logged in)
|
return unless user
|
||||||
|
|
||||||
if user.penning?
|
can :manage, :all if user.penning?
|
||||||
can :manage, :all
|
|
||||||
else
|
|
||||||
can :read, user, id: user.id
|
can :read, user, id: user.id
|
||||||
end
|
can :create, Transaction, debtor: user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,14 +10,10 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Client < ActiveRecord::Base
|
class Client < ActiveRecord::Base
|
||||||
|
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'
|
||||||
before_create :generate_key
|
before_create :generate_key
|
||||||
|
|
||||||
validates :name, presence: true, uniqueness: true
|
validates :name, presence: true, uniqueness: true
|
||||||
validates :key, presence: true, uniqueness: true
|
|
||||||
|
|
||||||
def transactions
|
|
||||||
Transaction.where(origin: name)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_key
|
def generate_key
|
||||||
|
|
8
app/models/client_ability.rb
Normal file
8
app/models/client_ability.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class Ability
|
||||||
|
include CanCan::Ability
|
||||||
|
|
||||||
|
def initialize(client)
|
||||||
|
client ||= Client.new # guest user (not logged in)
|
||||||
|
can :manage, :all
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,8 +5,9 @@
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# debtor_id :integer not null
|
# debtor_id :integer not null
|
||||||
# creditor_id :integer not null
|
# creditor_id :integer not null
|
||||||
|
# issuer_id :integer not null
|
||||||
|
# issuer_type :string not null
|
||||||
# amount :integer default(0), not null
|
# amount :integer default(0), not null
|
||||||
# origin :string not null
|
|
||||||
# message :string
|
# message :string
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
class Transaction < ActiveRecord::Base
|
class Transaction < ActiveRecord::Base
|
||||||
belongs_to :debtor, class_name: 'User'
|
belongs_to :debtor, class_name: 'User'
|
||||||
belongs_to :creditor, class_name: 'User'
|
belongs_to :creditor, class_name: 'User'
|
||||||
|
belongs_to :issuer, polymorphic: true
|
||||||
|
|
||||||
after_save :recalculate_balances
|
after_save :recalculate_balances
|
||||||
after_destroy :recalculate_balances
|
after_destroy :recalculate_balances
|
||||||
|
@ -22,10 +24,6 @@ class Transaction < ActiveRecord::Base
|
||||||
validates :amount, numericality: { greater_than: 0 }
|
validates :amount, numericality: { greater_than: 0 }
|
||||||
validate :different_debtor_creditor
|
validate :different_debtor_creditor
|
||||||
|
|
||||||
def client
|
|
||||||
Client.find_by name: origin
|
|
||||||
end
|
|
||||||
|
|
||||||
def peer_of(user)
|
def peer_of(user)
|
||||||
return creditor if user == debtor
|
return creditor if user == debtor
|
||||||
return debtor if user == creditor
|
return debtor if user == creditor
|
||||||
|
@ -44,6 +42,8 @@ class Transaction < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def different_debtor_creditor
|
def different_debtor_creditor
|
||||||
self.errors.add :base, "Can't write money to yourself" if self.debtor == self.creditor
|
if self.debtor == self.creditor
|
||||||
|
self.errors.add :base, "Can't write money to yourself"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,8 @@ class User < ActiveRecord::Base
|
||||||
has_many :outgoing_transactions,
|
has_many :outgoing_transactions,
|
||||||
class_name: 'Transaction', foreign_key: 'debtor_id'
|
class_name: 'Transaction', foreign_key: 'debtor_id'
|
||||||
|
|
||||||
|
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'
|
||||||
|
|
||||||
validates :name, presence: true, uniqueness: true
|
validates :name, presence: true, uniqueness: true
|
||||||
|
|
||||||
def transactions
|
def transactions
|
||||||
|
|
|
@ -7,5 +7,17 @@
|
||||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
%body
|
%body
|
||||||
= content_tag :div, flash[:alert] if flash[:alert]
|
.pure-g
|
||||||
|
.pure-u-1
|
||||||
|
.pure-menu.pure-menu-horizontal
|
||||||
|
%ul.pure-menu-list
|
||||||
|
- if current_user
|
||||||
|
%li.pure-menu-item
|
||||||
|
= link_to current_user.name.capitalize, current_user, class: "pure-menu-link"
|
||||||
|
%li.pure-menu-item
|
||||||
|
= link_to "New Transaction", new_transaction_path, class: "pure-menu-link"
|
||||||
|
- else
|
||||||
|
= link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user
|
||||||
|
.pure-u-1
|
||||||
|
= render 'partials/flash'
|
||||||
= yield
|
= yield
|
||||||
|
|
3
app/views/partials/_flash.html.haml
Normal file
3
app/views/partials/_flash.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
- flash.each do |key, value|
|
||||||
|
.pure-alert{ class: "pure-alert-#{key}" }
|
||||||
|
= value
|
10
app/views/partials/_form_errors.html.haml
Normal file
10
app/views/partials/_form_errors.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
- if object.errors.any?
|
||||||
|
.error_panel
|
||||||
|
.error_header
|
||||||
|
%h3.error_title
|
||||||
|
This transaction could not be saved.
|
||||||
|
.error_body
|
||||||
|
%ul
|
||||||
|
- object.errors.full_messages.each do |tr|
|
||||||
|
%li
|
||||||
|
= tr
|
|
@ -1,6 +1,13 @@
|
||||||
= @transaction.errors.full_messages.join(", ")
|
= render 'partials/form_errors', object: @transaction
|
||||||
= form_for @transaction do |f|
|
= simple_form_for @transaction do |f|
|
||||||
= f.collection_select :creditor_id, User.all, :id, :name, {}, { class: 'select2-selector' }
|
- if current_user.penning
|
||||||
= f.number_field :amount
|
= f.collection_select :debtor, User.all, :name, :name,
|
||||||
= f.text_field :message, required: true
|
{ selected: @transaction.debtor.try(:name) || current_user.name }, { class: 'select2-selector'}
|
||||||
= f.submit "Send it!"
|
- else
|
||||||
|
= f.hidden_field :debtor, value: current_user.name
|
||||||
|
= f.collection_select :creditor, User.all, :name, :name,
|
||||||
|
{ selected: @transaction.creditor.try(:name) || User.zeus.name }, { class: 'select2-selector' }
|
||||||
|
= f.input :message, required: true
|
||||||
|
= f.input :euros, input_html: { value: @transaction.amount/100}
|
||||||
|
.pure-controls
|
||||||
|
= f.button :submit, "Send it!"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th Amount
|
%th Amount
|
||||||
%th Origin
|
%th Issuer
|
||||||
%th Message
|
%th Message
|
||||||
%th Peer
|
%th Peer
|
||||||
%th Time
|
%th Time
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
= "<= Amount <="
|
= "<= Amount <="
|
||||||
%input.upper-bound{type: 'number', placeholder: 'upper', class: 'pure-u-1-5'}
|
%input.upper-bound{type: 'number', placeholder: 'upper', class: 'pure-u-1-5'}
|
||||||
%td.input-listen
|
%td.input-listen
|
||||||
%input{type: 'text', placeholder: 'Filter on Origin'}
|
%input{type: 'text', placeholder: 'Filter on Issuer'}
|
||||||
%td.input-listen
|
%td.input-listen
|
||||||
%input{type: 'text', placeholder: 'Filter on Message'}
|
%input{type: 'text', placeholder: 'Filter on Message'}
|
||||||
%td.input-listen
|
%td.input-listen
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
pagingType: 'full_numbers',
|
pagingType: 'full_numbers',
|
||||||
columns: [
|
columns: [
|
||||||
{ data: 'amount', name: 'Amount' },
|
{ data: 'amount', name: 'Amount' },
|
||||||
{ data: 'origin', name: 'Origin' },
|
{ data: 'issuer', name: 'Issuer' },
|
||||||
{ data: 'message', name: 'Message' },
|
{ data: 'message', name: 'Message' },
|
||||||
{ data: 'peer', name: 'Peer' },
|
{ data: 'peer', name: 'Peer' },
|
||||||
{ data: 'time', name: 'Time' }
|
{ data: 'time', name: 'Time' }
|
||||||
|
|
6
config/initializers/errbit.rb
Normal file
6
config/initializers/errbit.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Airbrake.configure do |config|
|
||||||
|
config.api_key = '066f6146dde14038b5ab69a2f680cd4a'
|
||||||
|
config.host = 'zeus-errbit.ilion.me'
|
||||||
|
config.port = 80
|
||||||
|
config.secure = config.port == 443
|
||||||
|
end
|
165
config/initializers/simple_form.rb
Normal file
165
config/initializers/simple_form.rb
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
# Use this setup block to configure all options available in SimpleForm.
|
||||||
|
SimpleForm.setup do |config|
|
||||||
|
# Wrappers are used by the form builder to generate a
|
||||||
|
# complete input. You can remove any component from the
|
||||||
|
# wrapper, change the order or even add your own to the
|
||||||
|
# stack. The options given below are used to wrap the
|
||||||
|
# whole input.
|
||||||
|
config.wrappers :default, class: "input pure-control-group",
|
||||||
|
hint_class: :field_with_hint, error_class: :field_with_errors do |b|
|
||||||
|
## Extensions enabled by default
|
||||||
|
# Any of these extensions can be disabled for a
|
||||||
|
# given input by passing: `f.input EXTENSION_NAME => false`.
|
||||||
|
# You can make any of these extensions optional by
|
||||||
|
# renaming `b.use` to `b.optional`.
|
||||||
|
|
||||||
|
# Determines whether to use HTML5 (:email, :url, ...)
|
||||||
|
# and required attributes
|
||||||
|
b.use :html5
|
||||||
|
|
||||||
|
# Calculates placeholders automatically from I18n
|
||||||
|
# You can also pass a string as f.input placeholder: "Placeholder"
|
||||||
|
b.use :placeholder
|
||||||
|
|
||||||
|
## Optional extensions
|
||||||
|
# They are disabled unless you pass `f.input EXTENSION_NAME => true`
|
||||||
|
# to the input. If so, they will retrieve the values from the model
|
||||||
|
# if any exists. If you want to enable any of those
|
||||||
|
# extensions by default, you can change `b.optional` to `b.use`.
|
||||||
|
|
||||||
|
# Calculates maxlength from length validations for string inputs
|
||||||
|
b.optional :maxlength
|
||||||
|
|
||||||
|
# Calculates pattern from format validations for string inputs
|
||||||
|
b.optional :pattern
|
||||||
|
|
||||||
|
# Calculates min and max from length validations for numeric inputs
|
||||||
|
b.optional :min_max
|
||||||
|
|
||||||
|
# Calculates readonly automatically from readonly attributes
|
||||||
|
b.optional :readonly
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
b.use :label_input
|
||||||
|
b.use :hint, wrap_with: { tag: :span, class: :hint }
|
||||||
|
b.use :error, wrap_with: { tag: :span, class: :error }
|
||||||
|
|
||||||
|
## full_messages_for
|
||||||
|
# If you want to display the full error message for the attribute, you can
|
||||||
|
# use the component :full_error, like:
|
||||||
|
#
|
||||||
|
# b.use :full_error, wrap_with: { tag: :span, class: :error }
|
||||||
|
end
|
||||||
|
|
||||||
|
# The default wrapper to be used by the FormBuilder.
|
||||||
|
config.default_wrapper = :default
|
||||||
|
|
||||||
|
# Define the way to render check boxes / radio buttons with labels.
|
||||||
|
# Defaults to :nested for bootstrap config.
|
||||||
|
# inline: input + label
|
||||||
|
# nested: label > input
|
||||||
|
config.boolean_style = :nested
|
||||||
|
|
||||||
|
# Default class for buttons
|
||||||
|
config.button_class = 'pure-button pure-button-primary'
|
||||||
|
|
||||||
|
# Method used to tidy up errors. Specify any Rails Array method.
|
||||||
|
# :first lists the first message for each field.
|
||||||
|
# Use :to_sentence to list all errors for each field.
|
||||||
|
# config.error_method = :first
|
||||||
|
|
||||||
|
# Default tag used for error notification helper.
|
||||||
|
config.error_notification_tag = :div
|
||||||
|
|
||||||
|
# CSS class to add for error notification helper.
|
||||||
|
config.error_notification_class = 'error_notification'
|
||||||
|
|
||||||
|
# ID to add for error notification helper.
|
||||||
|
# config.error_notification_id = nil
|
||||||
|
|
||||||
|
# Series of attempts to detect a default label method for collection.
|
||||||
|
# config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
|
||||||
|
|
||||||
|
# Series of attempts to detect a default value method for collection.
|
||||||
|
# config.collection_value_methods = [ :id, :to_s ]
|
||||||
|
|
||||||
|
# You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
|
||||||
|
# config.collection_wrapper_tag = nil
|
||||||
|
|
||||||
|
# You can define the class to use on all collection wrappers. Defaulting to none.
|
||||||
|
# config.collection_wrapper_class = nil
|
||||||
|
|
||||||
|
# You can wrap each item in a collection of radio/check boxes with a tag,
|
||||||
|
# defaulting to :span.
|
||||||
|
# config.item_wrapper_tag = :span
|
||||||
|
|
||||||
|
# You can define a class to use in all item wrappers. Defaulting to none.
|
||||||
|
# config.item_wrapper_class = nil
|
||||||
|
|
||||||
|
# How the label text should be generated altogether with the required text.
|
||||||
|
# config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
|
||||||
|
|
||||||
|
# You can define the class to use on all labels. Default is nil.
|
||||||
|
# config.label_class = nil
|
||||||
|
|
||||||
|
# You can define the default class to be used on forms. Can be overriden
|
||||||
|
# with `html: { :class }`. Defaulting to none.
|
||||||
|
config.default_form_class = "pure-form"
|
||||||
|
|
||||||
|
# You can define which elements should obtain additional classes
|
||||||
|
# config.generate_additional_classes_for = [:wrapper, :label, :input]
|
||||||
|
|
||||||
|
# Whether attributes are required by default (or not). Default is true.
|
||||||
|
# config.required_by_default = true
|
||||||
|
|
||||||
|
# Tell browsers whether to use the native HTML5 validations (novalidate form option).
|
||||||
|
# These validations are enabled in SimpleForm's internal config but disabled by default
|
||||||
|
# in this configuration, which is recommended due to some quirks from different browsers.
|
||||||
|
# To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
|
||||||
|
# change this configuration to true.
|
||||||
|
config.browser_validations = false
|
||||||
|
|
||||||
|
# Collection of methods to detect if a file type was given.
|
||||||
|
# config.file_methods = [ :mounted_as, :file?, :public_filename ]
|
||||||
|
|
||||||
|
# Custom mappings for input types. This should be a hash containing a regexp
|
||||||
|
# to match as key, and the input type that will be used when the field name
|
||||||
|
# matches the regexp as value.
|
||||||
|
# config.input_mappings = { /count/ => :integer }
|
||||||
|
|
||||||
|
# Custom wrappers for input types. This should be a hash containing an input
|
||||||
|
# type as key and the wrapper that will be used for all inputs with specified type.
|
||||||
|
# config.wrapper_mappings = { string: :prepend }
|
||||||
|
|
||||||
|
# Namespaces where SimpleForm should look for custom input classes that
|
||||||
|
# override default inputs.
|
||||||
|
# config.custom_inputs_namespaces << "CustomInputs"
|
||||||
|
|
||||||
|
# Default priority for time_zone inputs.
|
||||||
|
# config.time_zone_priority = nil
|
||||||
|
|
||||||
|
# Default priority for country inputs.
|
||||||
|
# config.country_priority = nil
|
||||||
|
|
||||||
|
# When false, do not use translations for labels.
|
||||||
|
# config.translate_labels = true
|
||||||
|
|
||||||
|
# Automatically discover new inputs in Rails' autoload path.
|
||||||
|
# config.inputs_discovery = true
|
||||||
|
|
||||||
|
# Cache SimpleForm inputs discovery
|
||||||
|
# config.cache_discovery = !Rails.env.development?
|
||||||
|
|
||||||
|
# Default class for inputs
|
||||||
|
# config.input_class = nil
|
||||||
|
|
||||||
|
# Define the default class of the input wrapper of the boolean input.
|
||||||
|
config.boolean_label_class = 'checkbox'
|
||||||
|
|
||||||
|
# Defines if the default input wrapper class should be included in radio
|
||||||
|
# collection wrappers.
|
||||||
|
# config.include_default_input_wrapper_class = true
|
||||||
|
|
||||||
|
# Defines which i18n scope will be used in Simple Form.
|
||||||
|
# config.i18n_scope = 'simple_form'
|
||||||
|
end
|
31
config/locales/simple_form.en.yml
Normal file
31
config/locales/simple_form.en.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
en:
|
||||||
|
simple_form:
|
||||||
|
"yes": 'Yes'
|
||||||
|
"no": 'No'
|
||||||
|
required:
|
||||||
|
text: 'required'
|
||||||
|
mark: '*'
|
||||||
|
# You can uncomment the line below if you need to overwrite the whole required html.
|
||||||
|
# When using html, text and mark won't be used.
|
||||||
|
# html: '<abbr title="required">*</abbr>'
|
||||||
|
error_notification:
|
||||||
|
default_message: "Please review the problems below:"
|
||||||
|
# Examples
|
||||||
|
# labels:
|
||||||
|
# defaults:
|
||||||
|
# password: 'Password'
|
||||||
|
# user:
|
||||||
|
# new:
|
||||||
|
# email: 'E-mail to sign in.'
|
||||||
|
# edit:
|
||||||
|
# email: 'E-mail.'
|
||||||
|
# hints:
|
||||||
|
# defaults:
|
||||||
|
# username: 'User name to sign in.'
|
||||||
|
# password: 'No special characters, please.'
|
||||||
|
# include_blanks:
|
||||||
|
# defaults:
|
||||||
|
# age: 'Rather not say'
|
||||||
|
# prompts:
|
||||||
|
# defaults:
|
||||||
|
# age: 'Select your age'
|
|
@ -3,8 +3,8 @@ class CreateTransactions < ActiveRecord::Migration
|
||||||
create_table :transactions do |t|
|
create_table :transactions do |t|
|
||||||
t.references :debtor, index: true, null: false
|
t.references :debtor, index: true, null: false
|
||||||
t.references :creditor, index: true, null: false
|
t.references :creditor, index: true, null: false
|
||||||
|
t.references :issuer, polymorphic: true, index: true, null: false
|
||||||
t.integer :amount, null: false, default: 0
|
t.integer :amount, null: false, default: 0
|
||||||
t.string :origin, null: false
|
|
||||||
t.string :message
|
t.string :message
|
||||||
|
|
||||||
t.timestamps null: false
|
t.timestamps null: false
|
||||||
|
|
|
@ -26,8 +26,9 @@ ActiveRecord::Schema.define(version: 20150908092731) do
|
||||||
create_table "transactions", force: :cascade do |t|
|
create_table "transactions", force: :cascade do |t|
|
||||||
t.integer "debtor_id", null: false
|
t.integer "debtor_id", null: false
|
||||||
t.integer "creditor_id", null: false
|
t.integer "creditor_id", null: false
|
||||||
|
t.integer "issuer_id", null: false
|
||||||
|
t.string "issuer_type", null: false
|
||||||
t.integer "amount", default: 0, null: false
|
t.integer "amount", default: 0, null: false
|
||||||
t.string "origin", null: false
|
|
||||||
t.string "message"
|
t.string "message"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
@ -35,6 +36,7 @@ ActiveRecord::Schema.define(version: 20150908092731) do
|
||||||
|
|
||||||
add_index "transactions", ["creditor_id"], name: "index_transactions_on_creditor_id"
|
add_index "transactions", ["creditor_id"], name: "index_transactions_on_creditor_id"
|
||||||
add_index "transactions", ["debtor_id"], name: "index_transactions_on_debtor_id"
|
add_index "transactions", ["debtor_id"], name: "index_transactions_on_debtor_id"
|
||||||
|
add_index "transactions", ["issuer_type", "issuer_id"], name: "index_transactions_on_issuer_type_and_issuer_id"
|
||||||
|
|
||||||
create_table "users", force: :cascade do |t|
|
create_table "users", force: :cascade do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
|
10
lib/templates/haml/scaffold/_form.html.haml
Normal file
10
lib/templates/haml/scaffold/_form.html.haml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
= simple_form_for(@<%= singular_table_name %>) do |f|
|
||||||
|
= f.error_notification
|
||||||
|
|
||||||
|
.form-inputs
|
||||||
|
<%- attributes.each do |attribute| -%>
|
||||||
|
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
||||||
|
<%- end -%>
|
||||||
|
|
||||||
|
.pure-controlls
|
||||||
|
= f.button :submit
|
|
@ -1,5 +1,78 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
RSpec.describe TransactionsController, type: :controller do
|
RSpec.describe TransactionsController, type: :controller do
|
||||||
|
describe "creating transaction" do
|
||||||
|
before :each do
|
||||||
|
@debtor = create(:user)
|
||||||
|
@creditor = create(:user)
|
||||||
|
sign_in @debtor
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with valid attributes" do
|
||||||
|
before :each do
|
||||||
|
@attributes = { transaction: {
|
||||||
|
debtor: @debtor.name,
|
||||||
|
creditor: @creditor.name,
|
||||||
|
cents: 70,
|
||||||
|
message: 'hoi'
|
||||||
|
}}
|
||||||
|
post :create, @attributes
|
||||||
|
@transaction = Transaction.last
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should create a new transaction" do
|
||||||
|
expect {post :create, @attributes}.to change {Transaction.count}.by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should set debtor" do
|
||||||
|
expect(@transaction.debtor).to eq(@debtor)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should set amount" do
|
||||||
|
expect(@transaction.amount).to eq(70)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should set creditor" do
|
||||||
|
expect(@transaction.creditor).to eq(@creditor)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should set issuer" do
|
||||||
|
expect(@transaction.issuer).to eq(@debtor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with float euros" do
|
||||||
|
it "should set correct amount" do
|
||||||
|
post :create, transaction: {
|
||||||
|
debtor: @debtor.name,
|
||||||
|
creditor: @creditor.name,
|
||||||
|
euros: 10.5,
|
||||||
|
message: "Omdat je een leuke jongen bent!"
|
||||||
|
}
|
||||||
|
expect(Transaction.last.amount).to eq(1050)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with negative amount" do
|
||||||
|
it "should be refused" do
|
||||||
|
expect do
|
||||||
|
post :create, transaction: attributes_for(:transaction, cents: -20)
|
||||||
|
end.not_to change {Transaction.count}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "for other user" do
|
||||||
|
it "should be refused" do
|
||||||
|
expect do
|
||||||
|
post :create, transaction: {
|
||||||
|
debtor: @creditor.name,
|
||||||
|
creditor: @debtor.name,
|
||||||
|
euros: 10000000,
|
||||||
|
message: 'DIT IS OVERVAL'
|
||||||
|
}
|
||||||
|
end.not_to change {Transaction.count}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# debtor_id :integer not null
|
# debtor_id :integer not null
|
||||||
# creditor_id :integer not null
|
# creditor_id :integer not null
|
||||||
|
# issuer_id :integer not null
|
||||||
|
# issuer_type :string not null
|
||||||
# amount :integer default(0), not null
|
# amount :integer default(0), not null
|
||||||
# origin :string not null
|
|
||||||
# message :string
|
# message :string
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
@ -16,8 +17,8 @@ FactoryGirl.define do
|
||||||
factory :transaction do
|
factory :transaction do
|
||||||
association :debtor, factory: :user
|
association :debtor, factory: :user
|
||||||
association :creditor, factory: :user
|
association :creditor, factory: :user
|
||||||
|
issuer { debtor }
|
||||||
amount { rand(100) }
|
amount { rand(100) }
|
||||||
origin 'FactoryGirl'
|
|
||||||
message { Faker::Lorem.sentence }
|
message { Faker::Lorem.sentence }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,5 +11,4 @@ require 'rails_helper'
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
RSpec.describe TransactionsHelper, type: :helper do
|
RSpec.describe TransactionsHelper, type: :helper do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,5 +11,4 @@ require 'rails_helper'
|
||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
RSpec.describe UsersHelper, type: :helper do
|
RSpec.describe UsersHelper, type: :helper do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
# id :integer not null, primary key
|
# id :integer not null, primary key
|
||||||
# debtor_id :integer not null
|
# debtor_id :integer not null
|
||||||
# creditor_id :integer not null
|
# creditor_id :integer not null
|
||||||
|
# issuer_id :integer not null
|
||||||
|
# issuer_type :string not null
|
||||||
# amount :integer default(0), not null
|
# amount :integer default(0), not null
|
||||||
# origin :string not null
|
|
||||||
# message :string
|
# message :string
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# Coveralls integrations
|
||||||
|
require 'coveralls'
|
||||||
|
Coveralls.wear!('rails')
|
||||||
|
|
||||||
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
||||||
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
||||||
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
||||||
|
@ -17,8 +21,10 @@
|
||||||
#
|
#
|
||||||
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
||||||
require 'factory_girl'
|
require 'factory_girl'
|
||||||
|
require 'devise'
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include FactoryGirl::Syntax::Methods
|
config.include FactoryGirl::Syntax::Methods
|
||||||
|
config.include Devise::TestHelpers, type: :controller
|
||||||
# rspec-expectations config goes here. You can use an alternate
|
# rspec-expectations config goes here. You can use an alternate
|
||||||
# assertion/expectation library such as wrong or the stdlib/minitest
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
||||||
# assertions if you prefer.
|
# assertions if you prefer.
|
||||||
|
|
Loading…
Reference in a new issue