Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge branch 'master' of github.com:/rapid7/warvox - warvox - VoIP based wardia…
Log
Files
Refs
README
---
commit 86414083dd5fbf42d0fba0b15cde689b5ad3abf5
parent de82e4afb0299e133c70f9cae641dca4058f9e6c
Author: HD Moore <[email protected]>
Date: Sun, 22 Nov 2015 14:01:37 -0600
Merge branch 'master' of github.com:/rapid7/warvox
Diffstat:
A .gitignore | 26 ++++++++++++++++++++++++++
A .ruby-version | 1 +
M Gemfile | 23 ++++++++++++++++++++++-
M Gemfile.lock | 141 +++++++++++++++++++++++++++++…
A Guardfile | 112 +++++++++++++++++++++++++++++…
M app/assets/stylesheets/application… | 2 +-
M app/controllers/application_contro… | 2 +-
M app/models/call.rb | 26 ++++++++++++++++++++++++++
M app/models/call_medium.rb | 16 ++++++++++++++++
M app/models/job.rb | 20 ++++++++++++++++++++
M app/models/line.rb | 13 +++++++++++++
M app/models/line_attribute.rb | 14 ++++++++++++++
M app/models/project.rb | 17 +++++++++++++++--
M app/models/provider.rb | 16 ++++++++++++++++
M app/models/settings.rb | 13 +++++++++++++
M app/models/signature.rb | 15 +++++++++++++++
M app/models/user.rb | 25 +++++++++++++++++++++++++
M app/views/projects/index.html.erb | 72 ++++++++++++++---------------…
A db/schema.rb | 191 +++++++++++++++++++++++++++++…
A spec/factories/call_media.rb | 23 +++++++++++++++++++++++
A spec/factories/calls.rb | 35 +++++++++++++++++++++++++++++…
A spec/factories/jobs.rb | 34 +++++++++++++++++++++++++++++…
A spec/factories/lines.rb | 20 ++++++++++++++++++++
A spec/factories/projects.rb | 21 +++++++++++++++++++++
A spec/factories/providers.rb | 28 ++++++++++++++++++++++++++++
A spec/factories/settings.rb | 19 +++++++++++++++++++
A spec/factories/signature_fps.rb | 6 ++++++
A spec/factories/signatures.rb | 26 ++++++++++++++++++++++++++
A spec/factories/users.rb | 35 +++++++++++++++++++++++++++++…
A spec/features/projects_spec.rb | 25 +++++++++++++++++++++++++
A spec/features/visitor/logins_spec.… | 58 +++++++++++++++++++++++++++…
A spec/models/call_medium_spec.rb | 26 ++++++++++++++++++++++++++
A spec/models/call_spec.rb | 38 +++++++++++++++++++++++++++++…
A spec/models/job_spec.rb | 32 +++++++++++++++++++++++++++++…
A spec/models/line_spec.rb | 23 +++++++++++++++++++++++
A spec/models/project_spec.rb | 30 ++++++++++++++++++++++++++++++
A spec/models/provider_spec.rb | 36 +++++++++++++++++++++++++++++…
A spec/models/settings_spec.rb | 20 ++++++++++++++++++++
A spec/models/signature_fp_spec.rb | 5 +++++
A spec/models/signature_spec.rb | 26 ++++++++++++++++++++++++++
A spec/models/user_spec.rb | 35 +++++++++++++++++++++++++++++…
A spec/rails_helper.rb | 55 +++++++++++++++++++++++++++++…
A spec/spec_helper.rb | 92 +++++++++++++++++++++++++++++…
A spec/support/auth_logic_helpers.rb | 21 +++++++++++++++++++++
D test/fixtures/dial_jobs.yml | 11 -----------
D test/fixtures/dial_results.yml | 11 -----------
D test/fixtures/providers.yml | 11 -----------
D test/functional/analyze_controller… | 8 --------
D test/functional/dial_jobs_controll… | 8 --------
D test/functional/dial_results_contr… | 8 --------
D test/functional/home_controller_te… | 8 --------
D test/functional/providers_controll… | 8 --------
D test/performance/browsing_test.rb | 9 ---------
D test/test_helper.rb | 13 -------------
D test/unit/dial_job_test.rb | 8 --------
D test/unit/dial_result_test.rb | 8 --------
D test/unit/helpers/analyze_helper_t… | 4 ----
D test/unit/helpers/dial_jobs_helper… | 4 ----
D test/unit/helpers/dial_results_hel… | 4 ----
D test/unit/helpers/home_helper_test… | 4 ----
D test/unit/helpers/providers_helper… | 4 ----
D test/unit/provider_test.rb | 8 --------
62 files changed, 1464 insertions(+), 189 deletions(-)
---
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,26 @@
+*.rbc
+capybara-*.html
+.rspec
+/log
+/tmp
+/db/*.sqlite3
+/db/*.sqlite3-journal
+/public/system
+/coverage/
+/spec/tmp
+**.orig
+rerun.txt
+pickle-email-*.html
+config/database.yml
+config/session.key
+
+# TODO Comment out these rules if you are OK with secrets being uploaded to th…
+config/initializers/secret_token.rb
+config/secrets.yml
+
+## Environment normalisation:
+/.bundle
+/vendor/bundle
+
+# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
+.rvmrc
diff --git a/.ruby-version b/.ruby-version
@@ -0,0 +1 @@
+2.2.3
diff --git a/Gemfile b/Gemfile
@@ -5,7 +5,7 @@ gem 'rails', '>=4.1.9', '< 4.2.0'
gem 'pg', '>=0.17'
gem 'jquery-rails', '>= 3.1.2'
-gem 'jquery-datatables-rails', '>= 2.2.3'
+gem 'jquery-datatables-rails', git: 'https://github.com/rweng/jquery-datatable…
#gem 'postgres_ext', :git => 'git://github.com/dockyard/postgres_ext.git'
gem 'kissfft'
@@ -35,3 +35,24 @@ gem 'will_paginate-bootstrap'
gem 'dynamic_form', '>= 1.1.4'
gem 'psych_shield'
gem 'scrypt'
+
+group :development do
+ gem 'guard-bundler'
+ gem 'guard-rails'
+ gem 'guard-rspec'
+ gem 'rails_layout'
+ gem 'guard-livereload', '~> 2.4', require: false
+ gem 'annotate'
+end
+group :development, :test do
+ gem 'factory_girl_rails'
+ gem 'faker'
+ gem 'rspec-rails'
+end
+group :test do
+ gem 'capybara'
+ gem 'database_cleaner'
+ gem 'launchy'
+ gem 'selenium-webdriver'
+ gem 'shoulda-matchers', '2.8'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
@@ -6,6 +6,16 @@ GIT
activerecord (>= 3.0)
activesupport (>= 3.0.0)
+GIT
+ remote: https://github.com/rweng/jquery-datatables-rails.git
+ revision: 9eee0a1975b5a22e50bdc73fcca7db7f8a12c143
+ specs:
+ jquery-datatables-rails (3.3.0)
+ actionpack (>= 3.1)
+ jquery-rails
+ railties (>= 3.1)
+ sass-rails
+
GEM
remote: http://rubygems.org/
specs:
@@ -35,6 +45,10 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
+ addressable (2.3.8)
+ annotate (2.6.10)
+ activerecord (>= 3.2, <= 4.3)
+ rake (~> 10.4)
arel (5.0.1.20140414130214)
authlogic (3.4.6)
activerecord (>= 3.2)
@@ -49,6 +63,15 @@ GEM
sass (>= 3.2.19)
breadcrumbs_on_rails (2.3.1)
builder (3.2.2)
+ capybara (2.5.0)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ xpath (~> 2.0)
+ childprocess (0.5.8)
+ ffi (~> 1.0, >= 1.0.11)
+ coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
@@ -56,41 +79,95 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.10.0)
+ database_cleaner (1.5.1)
+ diff-lcs (1.2.5)
dynamic_form (1.1.4)
+ em-websocket (0.5.1)
+ eventmachine (>= 0.12.9)
+ http_parser.rb (~> 0.6.0)
erubis (2.7.0)
+ eventmachine (1.0.8)
execjs (2.6.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.5.0)
+ i18n (~> 0.5)
ffi (1.9.10)
ffi-compiler (0.1.3)
ffi (>= 1.0.0)
rake
font-awesome-rails (4.4.0.0)
railties (>= 3.2, < 5.0)
+ formatador (0.2.5)
formtastic (3.1.3)
actionpack (>= 3.2.13)
formtastic-bootstrap (3.1.1)
formtastic (>= 3.0)
+ guard (2.13.0)
+ formatador (>= 0.2.4)
+ listen (>= 2.7, <= 4.0)
+ lumberjack (~> 1.0)
+ nenv (~> 0.1)
+ notiffany (~> 0.0)
+ pry (>= 0.9.12)
+ shellany (~> 0.0)
+ thor (>= 0.18.1)
+ guard-bundler (2.1.0)
+ bundler (~> 1.0)
+ guard (~> 2.2)
+ guard-compat (~> 1.1)
+ guard-compat (1.2.1)
+ guard-livereload (2.5.1)
+ em-websocket (~> 0.5)
+ guard (~> 2.8)
+ guard-compat (~> 1.0)
+ multi_json (~> 1.8)
+ guard-rails (0.7.2)
+ guard (~> 2.11)
+ guard-compat (~> 1.0)
+ guard-rspec (4.6.4)
+ guard (~> 2.1)
+ guard-compat (~> 1.1)
+ rspec (>= 2.99.0, < 4.0)
hike (1.2.3)
+ http_parser.rb (0.6.0)
i18n (0.7.0)
- jquery-datatables-rails (3.3.0)
- actionpack (>= 3.1)
- jquery-rails
- railties (>= 3.1)
- sass-rails
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
kgio (2.10.0)
kissfft (0.0.2)
+ launchy (2.4.3)
+ addressable (~> 2.3)
libv8 (3.16.14.13)
+ listen (3.0.5)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
+ lumberjack (1.0.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
+ method_source (0.8.2)
mime-types (2.99)
+ mini_portile (0.6.2)
minitest (5.8.3)
multi_json (1.11.2)
+ nenv (0.2.0)
+ nokogiri (1.6.6.4)
+ mini_portile (~> 0.6.0)
+ notiffany (0.0.8)
+ nenv (~> 0.1)
+ shellany (~> 0.0)
pg (0.18.4)
protected_attributes (1.0.9)
activemodel (>= 4.0.1, < 5.0)
+ pry (0.10.3)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
+ slop (~> 3.4)
psych_shield (0.0.4)
rack (1.5.5)
rack-test (0.6.3)
@@ -107,6 +184,7 @@ GEM
sprockets-rails (~> 2.0)
rails-settings-cached (0.4.1)
rails (>= 4.0.0)
+ rails_layout (1.0.28)
railties (4.1.14)
actionpack (= 4.1.14)
activesupport (= 4.1.14)
@@ -114,9 +192,34 @@ GEM
thor (>= 0.18.1, < 2.0)
raindrops (0.15.0)
rake (10.4.2)
+ rb-fsevent (0.9.6)
+ rb-inotify (0.9.5)
+ ffi (>= 0.5.0)
ref (2.0.0)
request_store (1.2.1)
rex (2.0.8)
+ rspec (3.4.0)
+ rspec-core (~> 3.4.0)
+ rspec-expectations (~> 3.4.0)
+ rspec-mocks (~> 3.4.0)
+ rspec-core (3.4.1)
+ rspec-support (~> 3.4.0)
+ rspec-expectations (3.4.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.4.0)
+ rspec-mocks (3.4.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.4.0)
+ rspec-rails (3.4.0)
+ actionpack (>= 3.0, < 4.3)
+ activesupport (>= 3.0, < 4.3)
+ railties (>= 3.0, < 4.3)
+ rspec-core (~> 3.4.0)
+ rspec-expectations (~> 3.4.0)
+ rspec-mocks (~> 3.4.0)
+ rspec-support (~> 3.4.0)
+ rspec-support (3.4.1)
+ rubyzip (1.1.7)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
@@ -126,6 +229,15 @@ GEM
scrypt (2.0.2)
ffi-compiler (>= 0.0.2)
rake
+ selenium-webdriver (2.48.1)
+ childprocess (~> 0.5)
+ multi_json (~> 1.0)
+ rubyzip (~> 1.0)
+ websocket (~> 1.0)
+ shellany (0.0.1)
+ shoulda-matchers (2.8.0)
+ activesupport (>= 3.0.0)
+ slop (3.6.0)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
@@ -150,35 +262,52 @@ GEM
kgio (~> 2.6)
rack
raindrops (~> 0.7)
+ websocket (1.2.2)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
+ xpath (2.0.0)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ annotate
authlogic (>= 3.4.0)
autoprefixer-rails
bootstrap-sass (>= 3.2.0)
breadcrumbs_on_rails
+ capybara
coffee-rails (~> 4.0.1)
+ database_cleaner
dynamic_form (>= 1.1.4)
+ factory_girl_rails
+ faker
font-awesome-rails
formtastic (>= 3.0.0)
formtastic-bootstrap (>= 3.0.0)
- jquery-datatables-rails (>= 2.2.3)
+ guard-bundler
+ guard-livereload (~> 2.4)
+ guard-rails
+ guard-rspec
+ jquery-datatables-rails!
jquery-rails (>= 3.1.2)
kissfft
+ launchy
pg (>= 0.17)
protected_attributes (~> 1.0.7)
psych_shield
rails (>= 4.1.9, < 4.2.0)
rails-settings-cached (>= 0.4.1)
+ rails_layout
reportable!
rex (~> 2.0.3)
+ rspec-rails
sass-rails (~> 4.0.2)
scrypt
+ selenium-webdriver
+ shoulda-matchers (= 2.8)
therubyracer
uglifier (>= 1.0.3)
unicorn
diff --git a/Guardfile b/Guardfile
@@ -0,0 +1,112 @@
+# A sample Guardfile
+# More info at https://github.com/guard/guard#readme
+
+## Uncomment and set this to only include directories you want to watch
+# directories %w(app lib config test spec features) \
+# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist"…
+
+## Note: if you are using the `directories` clause above and you are not
+## watching the project directory ('.'), then you will want to move
+## the Guardfile to a watched dir and symlink it back, e.g.
+#
+# $ mkdir config
+# $ mv Guardfile config/
+# $ ln -s config/Guardfile .
+#
+# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
+
+guard :bundler do
+ require 'guard/bundler'
+ require 'guard/bundler/verify'
+ helper = Guard::Bundler::Verify.new
+
+ files = ['Gemfile']
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
+
+ # Assume files are symlinked from somewhere
+ files.each { |file| watch(helper.real_path(file)) }
+end
+
+guard 'livereload' do
+ watch(%r{app/views/.+\.(erb|haml|slim)$})
+ watch(%r{app/helpers/.+\.rb})
+ watch(%r{public/.+\.(css|js|html)})
+ watch(%r{config/locales/.+\.yml})
+ # Rails Assets Pipeline
+ watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) { |m| "/a…
+end
+
+# Guard-Rails supports a lot options with default values:
+# daemon: false # runs the server as a daemon.
+# debugger: false # enable ruby-debug gem.
+# environment: 'development' # changes server environment.
+# force_run: false # kills any process that's holding the …
+# pid_file: 'tmp/pids/[RAILS_ENV].pid' # specify your pid_file.
+# host: 'localhost' # server hostname.
+# port: 3000 # server port number.
+# root: '/spec/dummy' # Rails' root path.
+# server: thin # webserver engine.
+# start_on_start: true # will start the server when starting G…
+# timeout: 30 # waits untill restarting the Rails ser…
+# zeus_plan: server # custom plan in zeus, only works with …
+# zeus: false # enables zeus gem.
+# CLI: 'rails server' # customizes runner command. Omits all …
+
+guard 'rails' do
+ watch('Gemfile.lock')
+ watch(%r{^(config|lib)/.*})
+end
+
+# Note: The cmd option is now required due to the increasing number of ways
+# rspec may be run, below are examples of the most common uses.
+# * bundler: 'bundle exec rspec'
+# * bundler binstubs: 'bin/rspec'
+# * spring: 'bin/rspec' (This will use spring if running and you have
+# installed the spring binstubs per the docs)
+# * zeus: 'zeus rspec' (requires the server to be started separately)
+# * 'just' rspec: 'rspec'
+
+guard :rspec, cmd: "bundle exec rspec" do
+ require "guard/rspec/dsl"
+ dsl = Guard::RSpec::Dsl.new(self)
+
+ # Feel free to open issues for suggestions and improvements
+
+ # RSpec files
+ rspec = dsl.rspec
+ watch(rspec.spec_helper) { rspec.spec_dir }
+ watch(rspec.spec_support) { rspec.spec_dir }
+ watch(rspec.spec_files)
+
+ # Ruby files
+ ruby = dsl.ruby
+ dsl.watch_spec_files_for(ruby.lib_files)
+
+ # Rails files
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
+ dsl.watch_spec_files_for(rails.app_files)
+ dsl.watch_spec_files_for(rails.views)
+
+ watch(rails.controllers) do |m|
+ [
+ rspec.spec.("routing/#{m[1]}_routing"),
+ rspec.spec.("controllers/#{m[1]}_controller"),
+ rspec.spec.("acceptance/#{m[1]}")
+ ]
+ end
+
+ # Rails config changes
+ watch(rails.spec_helper) { rspec.spec_dir }
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
+
+ # Capybara features specs
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
+
+ # Turnip features and steps
+ watch(%r{^spec/acceptance/(.+)\.feature$})
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
+ end
+end
diff --git a/app/assets/stylesheets/application.css.scss.erb b/app/assets/style…
@@ -4,7 +4,7 @@
*= require formtastic-bootstrap
*= require formtastic-overrides
*= require bootstrap-lightbox
- *= require jquery.dataTables
+ *= require dataTables/jquery.dataTables
*= require font-awesome
*/
diff --git a/app/controllers/application_controller.rb b/app/controllers/applic…
@@ -23,7 +23,7 @@ private
def require_user
unless current_user
store_location
- flash[:notice] = "You must be logged in to access this…
+ flash.now[:notice] = "You must be logged in to access …
redirect_to '/login'
return false
end
diff --git a/app/models/call.rb b/app/models/call.rb
@@ -1,3 +1,29 @@
+# == Schema Information
+#
+# Table name: calls
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# job_id :integer not null
+# provider_id :integer not null
+# answered :boolean
+# busy :boolean
+# error :text
+# audio_length :integer
+# ring_length :integer
+# caller_id :text
+# analysis_job_id :integer
+# analysis_started_at :datetime
+# analysis_completed_at :datetime
+# peak_freq :float
+# peak_freq_data :text
+# line_type :text
+# fprint :integer is an Array
+#
+
class Call < ActiveRecord::Base
reportable :hourly, :aggregation => :count, :grouping => :hour, :live_data =…
diff --git a/app/models/call_medium.rb b/app/models/call_medium.rb
@@ -1,3 +1,19 @@
+# == Schema Information
+#
+# Table name: call_media
+#
+# id :integer not null, primary key
+# call_id :integer not null
+# project_id :integer not null
+# audio :binary
+# mp3 :binary
+# png_big :binary
+# png_big_dots :binary
+# png_big_freq :binary
+# png_sig :binary
+# png_sig_freq :binary
+#
+
class CallMedium < ActiveRecord::Base
belongs_to :call
belongs_to :project
diff --git a/app/models/job.rb b/app/models/job.rb
@@ -1,3 +1,23 @@
+# == Schema Information
+#
+# Table name: jobs
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# project_id :integer not null
+# locked_by :string(255)
+# locked_at :datetime
+# started_at :datetime
+# completed_at :datetime
+# created_by :string(255)
+# task :string(255) not null
+# args :binary
+# status :string(255)
+# error :text
+# progress :integer default(0)
+#
+
class Job < ActiveRecord::Base
reportable :hourly, :aggregation => :count, :grouping => :hour, :date_…
diff --git a/app/models/line.rb b/app/models/line.rb
@@ -1,3 +1,16 @@
+# == Schema Information
+#
+# Table name: lines
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# line_type :text
+# notes :text
+#
+
class Line < ActiveRecord::Base
has_many :line_attributes, :dependent => :delete_all
belongs_to :project
diff --git a/app/models/line_attribute.rb b/app/models/line_attribute.rb
@@ -1,3 +1,17 @@
+# == Schema Information
+#
+# Table name: line_attributes
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# line_id :integer not null
+# project_id :integer not null
+# name :text not null
+# value :binary not null
+# content_type :string(255) default("text")
+#
+
class LineAttribute < ActiveRecord::Base
belongs_to :line
belongs_to :project
diff --git a/app/models/project.rb b/app/models/project.rb
@@ -1,8 +1,21 @@
-class Project < ActiveRecord::Base
+# == Schema Information
+#
+# Table name: projects
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# description :text
+# included :text
+# excluded :text
+# created_by :string(255)
+#
+class Project < ActiveRecord::Base
- validates :name, :uniqueness => true
validates_presence_of :name
+ validates_uniqueness_of :name
attr_accessible :name, :description, :included, :excluded
diff --git a/app/models/provider.rb b/app/models/provider.rb
@@ -1,3 +1,19 @@
+# == Schema Information
+#
+# Table name: providers
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# host :text not null
+# port :integer not null
+# user :text
+# pass :text
+# lines :integer default(1), not null
+# enabled :boolean default(TRUE)
+#
+
class Provider < ActiveRecord::Base
has_many :dial_results
diff --git a/app/models/settings.rb b/app/models/settings.rb
@@ -1,3 +1,16 @@
+# == Schema Information
+#
+# Table name: settings
+#
+# id :integer not null, primary key
+# var :string(255) not null
+# value :text
+# thing_id :integer
+# thing_type :string(30)
+# created_at :datetime
+# updated_at :datetime
+#
+
class Settings < RailsSettings::CachedSettings
attr_accessible :var
end
diff --git a/app/models/signature.rb b/app/models/signature.rb
@@ -1,3 +1,18 @@
+# == Schema Information
+#
+# Table name: signatures
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# source :string(255)
+# description :text
+# category :string(255)
+# line_type :string(255)
+# risk :integer
+#
+
class Signature < ActiveRecord::Base
has_many :signature_fps
diff --git a/app/models/user.rb b/app/models/user.rb
@@ -1,3 +1,28 @@
+# == Schema Information
+#
+# Table name: users
+#
+# id :integer not null, primary key
+# login :string(255) not null
+# email :string(255)
+# crypted_password :string(255) not null
+# password_salt :string(255) not null
+# persistence_token :string(255) not null
+# single_access_token :string(255) not null
+# perishable_token :string(255) not null
+# login_count :integer default(0), not null
+# failed_login_count :integer default(0), not null
+# last_request_at :datetime
+# current_login_at :datetime
+# last_login_at :datetime
+# current_login_ip :string(255)
+# last_login_ip :string(255)
+# created_at :datetime
+# updated_at :datetime
+# enabled :boolean default(TRUE)
+# admin :boolean default(TRUE)
+#
+
class User < ActiveRecord::Base
include RailsSettings::Extend
acts_as_authentic do |c|
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.…
@@ -1,46 +1,40 @@
-<% if @projects.length > 0 %>
<h1 class='title'>WarVOX Projects</h1>
+<p>
+ <a class="btn" href="<%= new_project_path %>">
+ <i class="fa fa-plus"></i> Create Project
+ </a>
+</p>
<%= will_paginate @projects, :renderer => BootstrapPagination::Rails %>
-<table class='table table-striped ' width='90%'>
- <thead>
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th>Jobs</th>
- <th>Calls</th>
- <th>Analyzed</th>
- <th>Created</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
-
-<% @projects.each do |project| %>
- <tr>
- <td><%= link_to( h(project.name), project_path(project)) %></td>
- <td><%=truncate(project.description, :length => 40, :separator => '') %></…
- <td><%= number_with_delimiter(project.jobs.count) %></td>
- <td><%= number_with_delimiter(project.calls.count) %></td>
- <td><%= number_with_delimiter(project.calls.where('analysis_completed_at I…
- <td><%= time_ago_in_words(project.created_at) %> ago</td>
- <td>
- <a class="btn" href="<%= edit_project_path(project) %>"rel="tool…
- <a class="btn" href="<%= project_path(project) %>" data-confirm="D…
- </td>
- </tr>
-
-<% end %>
-</tbody>
+<table id='projects-table' class='table table-striped' width='90%'>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>Jobs</th>
+ <th>Calls</th>
+ <th>Analyzed</th>
+ <th>Created</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @projects.each do |project| %>
+ <tr>
+ <td><%= link_to( h(project.name), project_path…
+ <td><%=truncate(project.description, :length =…
+ <td><%= number_with_delimiter(project.jobs.cou…
+ <td><%= number_with_delimiter(project.calls.co…
+ <td><%= number_with_delimiter(project.calls.wh…
+ <td><%= time_ago_in_words(project.created_at) …
+ <td>
+ <a class="btn" href="<%= edit_project_…
+ <a class="btn" href="<%= project_path(…
+ </td>
+ </tr>
+ <% end %>
+ </tbody>
</table>
<%= will_paginate @projects, :renderer => BootstrapPagination::Rails %>
-<% else %>
-
-<h1 class='title'>No Projects</h1>
-<br/>
-
-<% end %>
-
-<a class="btn" href="<%= new_project_path %>"><i class="fa fa-plus"></i> Creat…
diff --git a/db/schema.rb b/db/schema.rb
@@ -0,0 +1,191 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definiti…
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more mi…
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control…
+
+ActiveRecord::Schema.define(version: 20130113004653) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+ enable_extension "intarray"
+
+ create_table "call_media", force: true do |t|
+ t.integer "call_id", null: false
+ t.integer "project_id", null: false
+ t.binary "audio"
+ t.binary "mp3"
+ t.binary "png_big"
+ t.binary "png_big_dots"
+ t.binary "png_big_freq"
+ t.binary "png_sig"
+ t.binary "png_sig_freq"
+ end
+
+ add_index "call_media", ["call_id"], name: "index_call_media_on_call_id", us…
+ add_index "call_media", ["project_id"], name: "index_call_media_on_project_i…
+
+ create_table "calls", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.text "number", null: false
+ t.integer "project_id", null: false
+ t.integer "job_id", null: false
+ t.integer "provider_id", null: false
+ t.boolean "answered"
+ t.boolean "busy"
+ t.text "error"
+ t.integer "audio_length"
+ t.integer "ring_length"
+ t.text "caller_id"
+ t.integer "analysis_job_id"
+ t.datetime "analysis_started_at"
+ t.datetime "analysis_completed_at"
+ t.float "peak_freq"
+ t.text "peak_freq_data"
+ t.text "line_type"
+ t.integer "fprint", array: true
+ end
+
+ add_index "calls", ["job_id"], name: "index_calls_on_job_id", using: :btree
+ add_index "calls", ["number"], name: "index_calls_on_number", using: :btree
+ add_index "calls", ["provider_id"], name: "index_calls_on_provider_id", usin…
+
+ create_table "jobs", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "project_id", null: false
+ t.string "locked_by"
+ t.datetime "locked_at"
+ t.datetime "started_at"
+ t.datetime "completed_at"
+ t.string "created_by"
+ t.string "task", null: false
+ t.binary "args"
+ t.string "status"
+ t.text "error"
+ t.integer "progress", default: 0
+ end
+
+ add_index "jobs", ["project_id"], name: "index_jobs_on_project_id", using: :…
+
+ create_table "line_attributes", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "line_id", null: false
+ t.integer "project_id", null: false
+ t.text "name", null: false
+ t.binary "value", null: false
+ t.string "content_type", default: "text"
+ end
+
+ add_index "line_attributes", ["line_id"], name: "index_line_attributes_on_li…
+ add_index "line_attributes", ["project_id"], name: "index_line_attributes_on…
+
+ create_table "lines", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.text "number", null: false
+ t.integer "project_id", null: false
+ t.text "line_type"
+ t.text "notes"
+ end
+
+ add_index "lines", ["number"], name: "index_lines_on_number", using: :btree
+ add_index "lines", ["project_id"], name: "index_lines_on_project_id", using:…
+
+ create_table "projects", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.text "name", null: false
+ t.text "description"
+ t.text "included"
+ t.text "excluded"
+ t.string "created_by"
+ end
+
+ create_table "providers", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.text "name", null: false
+ t.text "host", null: false
+ t.integer "port", null: false
+ t.text "user"
+ t.text "pass"
+ t.integer "lines", default: 1, null: false
+ t.boolean "enabled", default: true
+ end
+
+ create_table "reportable_cache", force: true do |t|
+ t.string "model_name", limit: 100, null: false
+ t.string "report_name", limit: 100, null: false
+ t.string "grouping", limit: 10, null: false
+ t.string "aggregation", limit: 10, null: false
+ t.string "conditions", limit: 100, null: false
+ t.float "value", default: 0.0, null: false
+ t.datetime "reporting_period", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "reportable_cache", ["model_name", "report_name", "grouping", "agg…
+ add_index "reportable_cache", ["model_name", "report_name", "grouping", "agg…
+
+ create_table "settings", force: true do |t|
+ t.string "var", null: false
+ t.text "value"
+ t.integer "thing_id"
+ t.string "thing_type", limit: 30
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "settings", ["thing_type", "thing_id", "var"], name: "index_settin…
+
+ create_table "signature_fp", force: true do |t|
+ t.integer "signature_id", null: false
+ t.integer "fprint", array: true
+ end
+
+ add_index "signature_fp", ["signature_id"], name: "index_signature_fp_on_sig…
+
+ create_table "signatures", force: true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.text "name", null: false
+ t.string "source"
+ t.text "description"
+ t.string "category"
+ t.string "line_type"
+ t.integer "risk"
+ end
+
+ create_table "users", force: true do |t|
+ t.string "login", null: false
+ t.string "email"
+ t.string "crypted_password", null: false
+ t.string "password_salt", null: false
+ t.string "persistence_token", null: false
+ t.string "single_access_token", null: false
+ t.string "perishable_token", null: false
+ t.integer "login_count", default: 0, null: false
+ t.integer "failed_login_count", default: 0, null: false
+ t.datetime "last_request_at"
+ t.datetime "current_login_at"
+ t.datetime "last_login_at"
+ t.string "current_login_ip"
+ t.string "last_login_ip"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.boolean "enabled", default: true
+ t.boolean "admin", default: true
+ end
+
+end
diff --git a/spec/factories/call_media.rb b/spec/factories/call_media.rb
@@ -0,0 +1,23 @@
+# == Schema Information
+#
+# Table name: call_media
+#
+# id :integer not null, primary key
+# call_id :integer not null
+# project_id :integer not null
+# audio :binary
+# mp3 :binary
+# png_big :binary
+# png_big_dots :binary
+# png_big_freq :binary
+# png_sig :binary
+# png_sig_freq :binary
+#
+
+FactoryGirl.define do
+ factory :call_medium do
+ call
+ project
+ end
+
+end
diff --git a/spec/factories/calls.rb b/spec/factories/calls.rb
@@ -0,0 +1,35 @@
+# == Schema Information
+#
+# Table name: calls
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# job_id :integer not null
+# provider_id :integer not null
+# answered :boolean
+# busy :boolean
+# error :text
+# audio_length :integer
+# ring_length :integer
+# caller_id :text
+# analysis_job_id :integer
+# analysis_started_at :datetime
+# analysis_completed_at :datetime
+# peak_freq :float
+# peak_freq_data :text
+# line_type :text
+# fprint :integer is an Array
+#
+
+FactoryGirl.define do
+ factory :call do
+ project
+ job
+ provider
+ number { Faker::PhoneNumber.phone_number }
+ end
+
+end
diff --git a/spec/factories/jobs.rb b/spec/factories/jobs.rb
@@ -0,0 +1,34 @@
+# == Schema Information
+#
+# Table name: jobs
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# project_id :integer not null
+# locked_by :string(255)
+# locked_at :datetime
+# started_at :datetime
+# completed_at :datetime
+# created_by :string(255)
+# task :string(255) not null
+# args :binary
+# status :string(255)
+# error :text
+# progress :integer default(0)
+#
+
+FactoryGirl.define do
+ factory :job do
+ project
+ task 'dialer'
+ args "\x04\b{\t:\nrangeI\"\x0F7632458942\x06:\x06ET:\nlinesi\x…
+ status 'submitted'
+ error nil
+ range { Faker::PhoneNumber.phone_number }
+ cid_mask { Faker::PhoneNumber.phone_number }
+ seconds { Faker::Number.between(1, 299) }
+ lines { Faker::Number.between(1, 10000) }
+ end
+
+end
diff --git a/spec/factories/lines.rb b/spec/factories/lines.rb
@@ -0,0 +1,20 @@
+# == Schema Information
+#
+# Table name: lines
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# line_type :text
+# notes :text
+#
+
+FactoryGirl.define do
+ factory :line do
+ project
+ number { Faker::PhoneNumber.phone_number }
+ end
+
+end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
@@ -0,0 +1,21 @@
+# == Schema Information
+#
+# Table name: projects
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# description :text
+# included :text
+# excluded :text
+# created_by :string(255)
+#
+
+FactoryGirl.define do
+ factory :project do
+ name { Faker::Lorem.sentence }
+ description { Faker::Lorem.sentence }
+ end
+
+end
diff --git a/spec/factories/providers.rb b/spec/factories/providers.rb
@@ -0,0 +1,28 @@
+# == Schema Information
+#
+# Table name: providers
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# host :text not null
+# port :integer not null
+# user :text
+# pass :text
+# lines :integer default(1), not null
+# enabled :boolean default(TRUE)
+#
+
+FactoryGirl.define do
+ factory :provider do
+ name { Faker::Company.name }
+ host { Faker::Internet.ip_v4_address }
+ port { Faker::Number.between(1, 65535) }
+ user { Faker::Internet.user_name }
+ pass { Faker::Internet.password(10, 20) }
+ lines { Faker::Number.between(1, 254) }
+ enabled true
+ end
+
+end
diff --git a/spec/factories/settings.rb b/spec/factories/settings.rb
@@ -0,0 +1,19 @@
+# == Schema Information
+#
+# Table name: settings
+#
+# id :integer not null, primary key
+# var :string(255) not null
+# value :text
+# thing_id :integer
+# thing_type :string(30)
+# created_at :datetime
+# updated_at :datetime
+#
+
+FactoryGirl.define do
+ factory :setting, :class => 'Settings' do
+ var "CachedStuff"
+ end
+
+end
diff --git a/spec/factories/signature_fps.rb b/spec/factories/signature_fps.rb
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+ factory :signature_fp do
+
+ end
+
+end
diff --git a/spec/factories/signatures.rb b/spec/factories/signatures.rb
@@ -0,0 +1,26 @@
+# == Schema Information
+#
+# Table name: signatures
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# source :string(255)
+# description :text
+# category :string(255)
+# line_type :string(255)
+# risk :integer
+#
+
+FactoryGirl.define do
+ factory :signature do
+ name { Faker::Commerce.product_name }
+ source { Faker::PhoneNumber.cell_phone }
+ description { Faker::Lorem.sentence }
+ category { Faker::Lorem.word }
+ line_type { Faker::Lorem.word }
+ risk { Faker::Lorem.word }
+ end
+
+end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
@@ -0,0 +1,35 @@
+# == Schema Information
+#
+# Table name: users
+#
+# id :integer not null, primary key
+# login :string(255) not null
+# email :string(255)
+# crypted_password :string(255) not null
+# password_salt :string(255) not null
+# persistence_token :string(255) not null
+# single_access_token :string(255) not null
+# perishable_token :string(255) not null
+# login_count :integer default(0), not null
+# failed_login_count :integer default(0), not null
+# last_request_at :datetime
+# current_login_at :datetime
+# last_login_at :datetime
+# current_login_ip :string(255)
+# last_login_ip :string(255)
+# created_at :datetime
+# updated_at :datetime
+# enabled :boolean default(TRUE)
+# admin :boolean default(TRUE)
+#
+
+FactoryGirl.define do
+ factory :user do
+ login { Faker::Internet.user_name }
+ password 'RandomPass'
+ password_confirmation 'RandomPass'
+ enabled true
+ admin true
+ end
+
+end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
@@ -0,0 +1,25 @@
+require 'rails_helper'
+
+RSpec.feature "Projects", type: :feature do
+
+ before(:each) do
+ @user = create(:user)
+ create_user_session(@user)
+ end
+
+ it "list all existing projects" do
+ project = create(:project)
+ visit projects_path
+ expect(page).to have_content "WarVOX Projects"
+ within "#projects-table" do
+ expect(page).to have_content "Name"
+ expect(page).to have_content "Description"
+ expect(page).to have_content "Jobs"
+ expect(page).to have_content "Calls"
+ expect(page).to have_content "Analyzed"
+ expect(page).to have_content "Created"
+ expect(page).to have_content "Actions"
+ expect(page).to have_content project.name
+ end
+ end
+end
diff --git a/spec/features/visitor/logins_spec.rb b/spec/features/visitor/login…
@@ -0,0 +1,58 @@
+require 'rails_helper'
+
+RSpec.feature "Logins", type: :feature do
+ it "login with valid credentials" do
+ user = create(:user)
+ visit login_path
+ within "#new_user_session" do
+ expect(page).to have_content "Username"
+ expect(page).to have_content "Password"
+ fill_in "user_session_login", with: user.login
+ fill_in "user_session_password", with: 'RandomPass'
+ click_button "Sign in"
+ end
+ within "div.content" do
+ expect(page).to have_content "WarVOX Projects"
+ end
+ end
+
+ it "failed login with invalid password valid username" do
+ user = create(:user)
+ visit login_path
+ within "#new_user_session" do
+ fill_in "user_session_login", with: user.login
+ fill_in "user_session_password", with: 'WrongPassword'
+ click_button "Sign in"
+ end
+ expect(page).to have_content "Password is not valid"
+ end
+
+ it "failed login with invalid username valid password" do
+ user = create(:user)
+ visit login_path
+ within "#new_user_session" do
+ fill_in "user_session_login", with: user.login + "Wron…
+ fill_in "user_session_password", with: 'RandomPass'
+ click_button "Sign in"
+ end
+ expect(page).to have_content "Login is not valid"
+ end
+
+ it "failed login with no input entered" do
+ visit login_path
+ within "#new_user_session" do
+ click_button "Sign in"
+ end
+ expect(page).to have_content "You did not provide any details …
+ end
+
+ it "failed login with no password entered" do
+ user = create(:user)
+ visit login_path
+ within "#new_user_session" do
+ fill_in "user_session_login", with: user.login
+ click_button "Sign in"
+ end
+ expect(page).to have_content "Password cannot be blank"
+ end
+end
diff --git a/spec/models/call_medium_spec.rb b/spec/models/call_medium_spec.rb
@@ -0,0 +1,26 @@
+# == Schema Information
+#
+# Table name: call_media
+#
+# id :integer not null, primary key
+# call_id :integer not null
+# project_id :integer not null
+# audio :binary
+# mp3 :binary
+# png_big :binary
+# png_big_dots :binary
+# png_big_freq :binary
+# png_sig :binary
+# png_sig_freq :binary
+#
+
+require 'rails_helper'
+
+RSpec.describe CallMedium, type: :model do
+ it { should belong_to(:call) }
+ it { should belong_to(:project) }
+
+ it "valid record" do
+ expect(build(:call_medium)).to be_valid
+ end
+end
diff --git a/spec/models/call_spec.rb b/spec/models/call_spec.rb
@@ -0,0 +1,38 @@
+# == Schema Information
+#
+# Table name: calls
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# job_id :integer not null
+# provider_id :integer not null
+# answered :boolean
+# busy :boolean
+# error :text
+# audio_length :integer
+# ring_length :integer
+# caller_id :text
+# analysis_job_id :integer
+# analysis_started_at :datetime
+# analysis_completed_at :datetime
+# peak_freq :float
+# peak_freq_data :text
+# line_type :text
+# fprint :integer is an Array
+#
+
+require 'rails_helper'
+
+RSpec.describe Call, type: :model do
+ it { should belong_to(:project) }
+ it { should belong_to(:provider) }
+ it { should belong_to(:job) }
+ it { should have_one(:call_medium).dependent(:delete) }
+
+ it "valid record" do
+ expect(build(:call)).to be_valid
+ end
+end
diff --git a/spec/models/job_spec.rb b/spec/models/job_spec.rb
@@ -0,0 +1,32 @@
+# == Schema Information
+#
+# Table name: jobs
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# project_id :integer not null
+# locked_by :string(255)
+# locked_at :datetime
+# started_at :datetime
+# completed_at :datetime
+# created_by :string(255)
+# task :string(255) not null
+# args :binary
+# status :string(255)
+# error :text
+# progress :integer default(0)
+#
+
+require 'rails_helper'
+
+RSpec.describe Job, type: :model do
+ it { should belong_to(:project) }
+ it { should have_many(:calls) }
+
+ it { should validate_presence_of(:project_id) }
+
+ it "valid record" do
+ expect(build(:job)).to be_valid
+ end
+end
diff --git a/spec/models/line_spec.rb b/spec/models/line_spec.rb
@@ -0,0 +1,23 @@
+# == Schema Information
+#
+# Table name: lines
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# line_type :text
+# notes :text
+#
+
+require 'rails_helper'
+
+RSpec.describe Line, type: :model do
+ it { should belong_to(:project) }
+ it { should have_many(:line_attributes).dependent(:delete_all) }
+
+ it "valid record" do
+ expect(build(:line)).to be_valid
+ end
+end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
@@ -0,0 +1,30 @@
+# == Schema Information
+#
+# Table name: projects
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# description :text
+# included :text
+# excluded :text
+# created_by :string(255)
+#
+
+require 'rails_helper'
+
+RSpec.describe Project, type: :model do
+ it { should have_many(:lines).dependent(:delete_all) }
+ it { should have_many(:line_attributes).dependent(:delete_all) }
+ it { should have_many(:calls).dependent(:delete_all) }
+ it { should have_many(:call_media).dependent(:delete_all) }
+ it { should have_many(:jobs).dependent(:delete_all) }
+
+ it { should validate_presence_of(:name) }
+ it { should validate_uniqueness_of(:name) }
+
+ it "valid record" do
+ expect(build(:project)).to be_valid
+ end
+end
diff --git a/spec/models/provider_spec.rb b/spec/models/provider_spec.rb
@@ -0,0 +1,36 @@
+# == Schema Information
+#
+# Table name: providers
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# host :text not null
+# port :integer not null
+# user :text
+# pass :text
+# lines :integer default(1), not null
+# enabled :boolean default(TRUE)
+#
+
+require 'rails_helper'
+
+RSpec.describe Provider, type: :model do
+ ## TODO determine if association is unecessary
+ # the DialResult model does not exist
+ #it { should have_many(:dial_results) }
+
+ it { should validate_presence_of(:name) }
+ it { should validate_presence_of(:host) }
+ it { should validate_presence_of(:port) }
+ it { should validate_presence_of(:user) }
+ it { should validate_presence_of(:pass) }
+ it { should validate_presence_of(:lines) }
+ it { should validate_numericality_of(:port).is_less_than(65536).is_gre…
+ it { should validate_numericality_of(:lines).is_less_than(255).is_grea…
+
+ it "valid record" do
+ expect(build(:provider)).to be_valid
+ end
+end
diff --git a/spec/models/settings_spec.rb b/spec/models/settings_spec.rb
@@ -0,0 +1,20 @@
+# == Schema Information
+#
+# Table name: settings
+#
+# id :integer not null, primary key
+# var :string(255) not null
+# value :text
+# thing_id :integer
+# thing_type :string(30)
+# created_at :datetime
+# updated_at :datetime
+#
+
+require 'rails_helper'
+
+RSpec.describe Settings, type: :model do
+ it "valid record" do
+ expect(build(:setting)).to be_valid
+ end
+end
diff --git a/spec/models/signature_fp_spec.rb b/spec/models/signature_fp_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe SignatureFp, type: :model do
+
+end
diff --git a/spec/models/signature_spec.rb b/spec/models/signature_spec.rb
@@ -0,0 +1,26 @@
+# == Schema Information
+#
+# Table name: signatures
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# name :text not null
+# source :string(255)
+# description :text
+# category :string(255)
+# line_type :string(255)
+# risk :integer
+#
+
+require 'rails_helper'
+
+RSpec.describe Signature, type: :model do
+ ## TODO association may not be needed
+ # causes crash: PG::UndefinedTable: ERROR: relation "signature_fps" …
+ #it { should have_many(:signature_fps) }
+
+ it "valid record" do
+ expect(build(:signature)).to be_valid
+ end
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
@@ -0,0 +1,35 @@
+# == Schema Information
+#
+# Table name: users
+#
+# id :integer not null, primary key
+# login :string(255) not null
+# email :string(255)
+# crypted_password :string(255) not null
+# password_salt :string(255) not null
+# persistence_token :string(255) not null
+# single_access_token :string(255) not null
+# perishable_token :string(255) not null
+# login_count :integer default(0), not null
+# failed_login_count :integer default(0), not null
+# last_request_at :datetime
+# current_login_at :datetime
+# last_login_at :datetime
+# current_login_ip :string(255)
+# last_login_ip :string(255)
+# created_at :datetime
+# updated_at :datetime
+# enabled :boolean default(TRUE)
+# admin :boolean default(TRUE)
+#
+
+require 'rails_helper'
+
+RSpec.describe User, type: :model do
+ it { should validate_length_of(:password).is_at_least(8) }
+ it { should validate_length_of(:password_confirmation).is_at_least(8) }
+
+ it 'valid record' do
+ expect(build(:user)).to be_valid
+ end
+end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
@@ -0,0 +1,55 @@
+# This file is copied to spec/ when you run 'rails generate rspec:install'
+ENV['RAILS_ENV'] ||= 'test'
+require File.expand_path('../../config/environment', __FILE__)
+# Prevent database truncation if the environment is production
+abort("The Rails environment is running in production mode!") if Rails.env.pro…
+require 'spec_helper'
+require 'rspec/rails'
+# Add additional requires below this line. Rails is not loaded until this poin…
+
+# Requires supporting ruby files with custom matchers and macros, etc, in
+# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
+# run as spec files by default. This means that files in spec/support that end
+# in _spec.rb will both be required and run as specs, causing the specs to be
+# run twice. It is recommended that you do not name files matching this glob to
+# end with _spec.rb. You can configure this pattern with the --pattern
+# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
+#
+# The following line is provided for convenience purposes. It has the downside
+# of increasing the boot-up time by auto-requiring all files in the support
+# directory. Alternatively, in the individual `*_spec.rb` files, manually
+# require only the support files necessary.
+#
+Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
+
+# Checks for pending migrations before tests are run.
+# If you are not using ActiveRecord, you can remove this line.
+ActiveRecord::Migration.maintain_test_schema!
+
+RSpec.configure do |config|
+ # FactoryGirl Syntax
+ config.include FactoryGirl::Syntax::Methods
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fi…
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of…
+ # examples within a transaction, remove the following line or assign f…
+ # instead of true.
+ config.use_transactional_fixtures = true
+
+ # RSpec Rails can automatically mix in different behaviours to your te…
+ # based on their file location, for example enabling you to call `get`…
+ # `post` in specs under `spec/controllers`.
+ #
+ # You can disable this behaviour by removing the line below, and inste…
+ # explicitly tag your specs with their type, e.g.:
+ #
+ # RSpec.describe UsersController, :type => :controller do
+ # # ...
+ # end
+ #
+ # The different available types are documented in the features, such a…
+ # https://relishapp.com/rspec/rspec-rails/docs
+ config.infer_spec_type_from_file_location!
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
@@ -0,0 +1,92 @@
+# This file was generated by the `rails generate rspec:install` command. Conve…
+# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
+# The generated `.rspec` file contains `--require spec_helper` which will cause
+# this file to always be loaded, without a need to explicitly require it in any
+# files.
+#
+# Given that it is always loaded, you are encouraged to keep this file as
+# light-weight as possible. Requiring heavyweight dependencies from this file
+# will add to the boot time of your test suite on EVERY test run, even for an
+# individual file that may not need all of that loaded. Instead, consider maki…
+# a separate helper file that requires the additional dependencies and performs
+# the additional setup, and require it from the spec files that actually need
+# it.
+#
+# The `.rspec` file also contains a few flags that are not defaults but that
+# users commonly want.
+#
+# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+RSpec.configure do |config|
+ # rspec-expectations config goes here. You can use an alternate
+ # assertion/expectation library such as wrong or the stdlib/minitest
+ # assertions if you prefer.
+ config.expect_with :rspec do |expectations|
+ # This option will default to `true` in RSpec 4. It makes the `description`
+ # and `failure_message` of custom matchers include text for helper methods
+ # defined using `chain`, e.g.:
+ # be_bigger_than(2).and_smaller_than(4).description
+ # # => "be bigger than 2 and smaller than 4"
+ # ...rather than:
+ # # => "be bigger than 2"
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
+ end
+
+ # rspec-mocks config goes here. You can use an alternate test double
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
+ config.mock_with :rspec do |mocks|
+ # Prevents you from mocking or stubbing a method that does not exist on
+ # a real object. This is generally recommended, and will default to
+ # `true` in RSpec 4.
+ mocks.verify_partial_doubles = true
+ end
+
+# The settings below are suggested to provide a good initial experience
+# with RSpec, but feel free to customize to your heart's content.
+=begin
+ # These two settings work together to allow you to limit a spec run
+ # to individual examples or groups you care about by tagging them with
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
+ # get run.
+ config.filter_run :focus
+ config.run_all_when_everything_filtered = true
+
+ # Allows RSpec to persist some state between runs in order to support
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
+ # you configure your source control system to ignore this file.
+ config.example_status_persistence_file_path = "spec/examples.txt"
+
+ # Limits the available syntax to the non-monkey patched syntax that is
+ # recommended. For more details, see:
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectatio…
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new_…
+ config.disable_monkey_patching!
+
+ # Many RSpec users commonly either run the entire suite or an individual
+ # file, and it's useful to allow more verbose output when running an
+ # individual spec file.
+ if config.files_to_run.one?
+ # Use the documentation formatter for detailed output,
+ # unless a formatter has already been configured
+ # (e.g. via a command-line flag).
+ config.default_formatter = 'doc'
+ end
+
+ # Print the 10 slowest examples and example groups at the
+ # end of the spec run, to help surface which specs are running
+ # particularly slow.
+ config.profile_examples = 10
+
+ # Run specs in random order to surface order dependencies. If you find an
+ # order dependency and want to debug it, you can fix the order by providing
+ # the seed, which is printed after each run.
+ # --seed 1234
+ config.order = :random
+
+ # Seed global randomization in this process using the `--seed` CLI option.
+ # Setting this allows you to use `--seed` to deterministically reproduce
+ # test failures related to randomization by passing the same `--seed` value
+ # as the one that triggered the failure.
+ Kernel.srand config.seed
+=end
+end
diff --git a/spec/support/auth_logic_helpers.rb b/spec/support/auth_logic_helpe…
@@ -0,0 +1,20 @@
+module Authlogic
+ module TestHelper
+ def create_user_session(user)
+ visit login_path
+ within "#new_user_session" do
+ expect(page).to have_content "Username"
+ expect(page).to have_content "Password"
+ fill_in "user_session_login", with: user.login
+ fill_in "user_session_password", with: user.pa…
+ click_button "Sign in"
+ end
+ end
+ end
+end
+
+# Make this available to just the request and feature specs
+RSpec.configure do |config|
+ config.include Authlogic::TestHelper, type: :request
+ config.include Authlogic::TestHelper, type: :feature
+end
+\ No newline at end of file
diff --git a/test/fixtures/dial_jobs.yml b/test/fixtures/dial_jobs.yml
@@ -1,11 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.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
diff --git a/test/fixtures/dial_results.yml b/test/fixtures/dial_results.yml
@@ -1,11 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.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
diff --git a/test/fixtures/providers.yml b/test/fixtures/providers.yml
@@ -1,11 +0,0 @@
-# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.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
diff --git a/test/functional/analyze_controller_test.rb b/test/functional/analy…
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class AnalyzeControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/functional/dial_jobs_controller_test.rb b/test/functional/dia…
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class DialJobsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/functional/dial_results_controller_test.rb b/test/functional/…
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class DialResultsControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/functional/home_controller_test.rb b/test/functional/home_con…
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class HomeControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/functional/providers_controller_test.rb b/test/functional/pro…
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class ProvidersControllerTest < ActionController::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test…
@@ -1,9 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-# Profiling results for each test method are written to tmp/performance.
-class BrowsingTest < ActionDispatch::PerformanceTest
- def test_homepage
- get '/'
- end
-end
diff --git a/test/test_helper.rb b/test/test_helper.rb
@@ -1,13 +0,0 @@
-ENV["RAILS_ENV"] = "test"
-require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabeti…
- #
- # Note: You'll currently still have to declare fixtures explicitly in integr…
- # -- they do not yet inherit this setting
- fixtures :all
-
- # Add more helper methods to be used by all tests here...
-end
diff --git a/test/unit/dial_job_test.rb b/test/unit/dial_job_test.rb
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class DialJobTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/unit/dial_result_test.rb b/test/unit/dial_result_test.rb
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class DialResultTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
diff --git a/test/unit/helpers/analyze_helper_test.rb b/test/unit/helpers/analy…
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class AnalyzeHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/dial_jobs_helper_test.rb b/test/unit/helpers/dia…
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class DialJobsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/dial_results_helper_test.rb b/test/unit/helpers/…
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class DialResultsHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/home_helper_test.rb b/test/unit/helpers/home_hel…
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class HomeHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/helpers/providers_helper_test.rb b/test/unit/helpers/pro…
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class ProvidersHelperTest < ActionView::TestCase
-end
diff --git a/test/unit/provider_test.rb b/test/unit/provider_test.rb
@@ -1,8 +0,0 @@
-require 'test_helper'
-
-class ProviderTest < ActiveSupport::TestCase
- # Replace this with your real tests.
- test "the truth" do
- assert true
- end
-end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.