mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
setup test environment and add the first test
This commit is contained in:
parent
7dd7fb13f6
commit
fafec2153c
10
Gemfile
10
Gemfile
@ -34,12 +34,6 @@ group :development, :test do
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
|
||||
gem 'factory_girl_rails'
|
||||
gem 'rspec-rails'
|
||||
gem 'spring-commands-rspec'
|
||||
|
||||
gem 'guard-rspec', require: false
|
||||
|
||||
gem 'railroady'
|
||||
end
|
||||
|
||||
@ -62,6 +56,8 @@ end
|
||||
group :test do
|
||||
gem 'database_cleaner'
|
||||
gem 'faker'
|
||||
gem 'test_after_commit'
|
||||
gem 'minitest-reporters'
|
||||
end
|
||||
|
||||
group :production do
|
||||
@ -137,4 +133,4 @@ gem 'chroma'
|
||||
|
||||
gem 'protected_attributes'
|
||||
|
||||
gem 'message_format'
|
||||
gem 'message_format'
|
||||
|
78
Gemfile.lock
78
Gemfile.lock
@ -41,6 +41,7 @@ GEM
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.3.8)
|
||||
ansi (1.5.0)
|
||||
arel (6.0.3)
|
||||
autoprefixer-rails (5.1.8)
|
||||
execjs
|
||||
@ -80,7 +81,6 @@ GEM
|
||||
chroma (0.0.1)
|
||||
chunky_png (1.3.4)
|
||||
cldr-plurals-runtime-rb (1.0.1)
|
||||
coderay (1.1.0)
|
||||
coercible (1.0.0)
|
||||
descendants_tracker (~> 0.0.1)
|
||||
coffee-rails (4.1.0)
|
||||
@ -120,7 +120,6 @@ GEM
|
||||
warden (~> 1.2.3)
|
||||
devise-async (0.9.0)
|
||||
devise (~> 3.2)
|
||||
diff-lcs (1.2.5)
|
||||
domain_name (0.5.25)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
elasticsearch (1.0.12)
|
||||
@ -146,11 +145,6 @@ GEM
|
||||
equalizer (0.0.11)
|
||||
erubis (2.7.0)
|
||||
execjs (2.4.0)
|
||||
factory_girl (4.5.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.5.0)
|
||||
factory_girl (~> 4.5.0)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.4.3)
|
||||
i18n (~> 0.5)
|
||||
faraday (0.9.1)
|
||||
@ -163,25 +157,10 @@ GEM
|
||||
foreman (0.78.0)
|
||||
thor (~> 0.19.1)
|
||||
forgery (0.6.0)
|
||||
formatador (0.2.5)
|
||||
friendly_id (5.1.0)
|
||||
activerecord (>= 4.0.0)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
guard (2.12.5)
|
||||
formatador (>= 0.2.4)
|
||||
listen (~> 2.7)
|
||||
lumberjack (~> 1.0)
|
||||
nenv (~> 0.1)
|
||||
notiffany (~> 0.0)
|
||||
pry (>= 0.9.12)
|
||||
shellany (~> 0.0)
|
||||
thor (>= 0.18.1)
|
||||
guard-compat (1.2.1)
|
||||
guard-rspec (4.5.0)
|
||||
guard (~> 2.1)
|
||||
guard-compat (~> 1.1)
|
||||
rspec (>= 2.99.0, < 4.0)
|
||||
hashie (3.4.2)
|
||||
highline (1.7.1)
|
||||
hike (1.2.3)
|
||||
@ -211,29 +190,27 @@ GEM
|
||||
letter_opener (1.3.0)
|
||||
launchy (~> 2.2)
|
||||
libv8 (3.16.14.11)
|
||||
listen (2.10.0)
|
||||
celluloid (~> 0.16.0)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
lumberjack (1.0.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
memoizable (0.4.2)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
message_format (0.0.3)
|
||||
twitter_cldr (~> 3.1)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.99)
|
||||
mini_magick (4.2.0)
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.8.3)
|
||||
minitest-reporters (1.1.8)
|
||||
ansi
|
||||
builder
|
||||
minitest (>= 5.0)
|
||||
ruby-progressbar
|
||||
multi_json (1.11.2)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
naught (1.0.0)
|
||||
nenv (0.2.0)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-sftp (2.1.2)
|
||||
@ -244,9 +221,6 @@ GEM
|
||||
netrc (0.10.3)
|
||||
nokogiri (1.6.6.4)
|
||||
mini_portile (~> 0.6.0)
|
||||
notiffany (0.0.6)
|
||||
nenv (~> 0.1)
|
||||
shellany (~> 0.0)
|
||||
notify_with (0.0.2)
|
||||
jbuilder (~> 2.0)
|
||||
rails (>= 4.2.0)
|
||||
@ -273,10 +247,6 @@ GEM
|
||||
prawn-table (0.2.1)
|
||||
protected_attributes (1.1.3)
|
||||
activemodel (>= 4.0.1, < 5.0)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
slop (~> 3.4)
|
||||
puma (2.11.1)
|
||||
rack (>= 1.1, < 2.0)
|
||||
pundit (1.0.0)
|
||||
@ -338,27 +308,7 @@ GEM
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rolify (4.0.0)
|
||||
rspec (3.2.0)
|
||||
rspec-core (~> 3.2.0)
|
||||
rspec-expectations (~> 3.2.0)
|
||||
rspec-mocks (~> 3.2.0)
|
||||
rspec-core (3.2.2)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-expectations (3.2.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-mocks (3.2.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-rails (3.2.1)
|
||||
actionpack (>= 3.0, < 4.3)
|
||||
activesupport (>= 3.0, < 4.3)
|
||||
railties (>= 3.0, < 4.3)
|
||||
rspec-core (~> 3.2.0)
|
||||
rspec-expectations (~> 3.2.0)
|
||||
rspec-mocks (~> 3.2.0)
|
||||
rspec-support (~> 3.2.0)
|
||||
rspec-support (3.2.2)
|
||||
ruby-progressbar (1.7.5)
|
||||
rufus-scheduler (3.0.9)
|
||||
tzinfo
|
||||
rvm-capistrano (1.5.6)
|
||||
@ -376,7 +326,6 @@ GEM
|
||||
seed_dump (3.2.2)
|
||||
activerecord (~> 4)
|
||||
activesupport (~> 4)
|
||||
shellany (0.0.1)
|
||||
sidekiq (3.3.4)
|
||||
celluloid (>= 0.16.0)
|
||||
connection_pool (>= 2.1.1)
|
||||
@ -392,10 +341,7 @@ GEM
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.4)
|
||||
tilt (>= 1.3, < 3)
|
||||
slop (3.6.0)
|
||||
spring (1.3.5)
|
||||
spring-commands-rspec (1.0.4)
|
||||
spring (>= 0.9.1)
|
||||
sprockets (2.12.4)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
@ -408,6 +354,8 @@ GEM
|
||||
stripe (1.30.2)
|
||||
json (~> 1.8.1)
|
||||
rest-client (~> 1.4)
|
||||
test_after_commit (1.0.0)
|
||||
activerecord (>= 3.2)
|
||||
therubyracer (0.12.0)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
@ -482,20 +430,19 @@ DEPENDENCIES
|
||||
elasticsearch-model
|
||||
elasticsearch-persistence
|
||||
elasticsearch-rails
|
||||
factory_girl_rails
|
||||
faker
|
||||
figaro
|
||||
font-awesome-rails
|
||||
foreman
|
||||
forgery
|
||||
friendly_id (~> 5.1.0)
|
||||
guard-rspec
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
kaminari
|
||||
letter_opener
|
||||
message_format
|
||||
mini_magick
|
||||
minitest-reporters
|
||||
notify_with
|
||||
oj
|
||||
omniauth
|
||||
@ -513,7 +460,6 @@ DEPENDENCIES
|
||||
recurrence
|
||||
responders (~> 2.0)
|
||||
rolify
|
||||
rspec-rails
|
||||
rvm-capistrano
|
||||
sass-rails (= 5.0.1)
|
||||
sdoc (~> 0.4.0)
|
||||
@ -522,8 +468,8 @@ DEPENDENCIES
|
||||
sidekiq-cron
|
||||
sinatra
|
||||
spring
|
||||
spring-commands-rspec
|
||||
stripe (= 1.30.2)
|
||||
test_after_commit
|
||||
therubyracer (= 0.12.0)
|
||||
twitter
|
||||
twitter-text
|
||||
@ -532,4 +478,4 @@ DEPENDENCIES
|
||||
web-console (~> 2.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
||||
1.11.2
|
||||
|
@ -64,13 +64,13 @@ class Availability < ActiveRecord::Base
|
||||
private
|
||||
def length_must_be_1h_minimum
|
||||
if end_at < (start_at + 1.hour)
|
||||
errors.add(:end_at, t('availabilities.must_be_at_least_1_hour_after_the_start_date'))
|
||||
errors.add(:end_at, I18n.t('availabilities.must_be_at_least_1_hour_after_the_start_date'))
|
||||
end
|
||||
end
|
||||
|
||||
def should_be_associated
|
||||
if available_type == 'machines' and machine_ids.count == 0
|
||||
errors.add(:machine_ids, t('availabilities.must_be_associated_with_at_least_1_machine'))
|
||||
errors.add(:machine_ids, I18n.t('availabilities.must_be_associated_with_at_least_1_machine'))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -39,6 +39,6 @@ Rails.application.configure do
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
||||
|
||||
config.active_support.test_order = :random
|
||||
|
||||
end
|
||||
|
11
test/fixtures/availabilities.yml
vendored
Normal file
11
test/fixtures/availabilities.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
9
test/models/availability_test.rb
Normal file
9
test/models/availability_test.rb
Normal file
@ -0,0 +1,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class AvailabilityTest < ActiveSupport::TestCase
|
||||
test "length must be at least 1h" do
|
||||
a = Availability.new(start_at: Time.now, end_at: 15.minutes.from_now)
|
||||
assert a.invalid?
|
||||
assert a.errors.key?(:end_at)
|
||||
end
|
||||
end
|
@ -1,7 +1,20 @@
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/test_help'
|
||||
require 'sidekiq/testing'
|
||||
Sidekiq::Testing.fake!
|
||||
|
||||
require 'minitest/reporters'
|
||||
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new({ color: true })]
|
||||
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Add more helper methods to be used by all tests here...
|
||||
|
||||
fixtures :all
|
||||
end
|
||||
|
||||
class ActionDispatch::IntegrationTest
|
||||
include Warden::Test::Helpers
|
||||
Warden.test_mode!
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user