| added rspec test suite, annotate gem to help illustrate models better for colla… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit c55d42528abe10c13d07ebada9f8b47965a3a82f | |
| parent e23374a007b861e1c440fd3fee65dbc9d29a4f94 | |
| Author: zeknox <[email protected]> | |
| Date: Fri, 23 Oct 2015 16:11:14 -0500 | |
| added rspec test suite, annotate gem to help illustrate models better for colla… | |
| Diffstat: | |
| M Gemfile | 21 +++++++++++++++++++++ | |
| M Gemfile.lock | 123 +++++++++++++++++++++++++++++… | |
| A Guardfile | 112 +++++++++++++++++++++++++++++… | |
| 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 | 14 ++++++++++++++ | |
| M app/models/provider.rb | 16 ++++++++++++++++ | |
| M app/models/settings.rb | 13 +++++++++++++ | |
| M app/models/signature.rb | 15 +++++++++++++++ | |
| M app/models/user.rb | 25 +++++++++++++++++++++++++ | |
| A db/schema.rb | 191 +++++++++++++++++++++++++++++… | |
| A spec/factories/users.rb | 31 +++++++++++++++++++++++++++++… | |
| A spec/models/user_spec.rb | 30 ++++++++++++++++++++++++++++++ | |
| A spec/rails_helper.rb | 52 +++++++++++++++++++++++++++++… | |
| A spec/spec_helper.rb | 92 +++++++++++++++++++++++++++++… | |
| 18 files changed, 824 insertions(+), 0 deletions(-) | |
| --- | |
| diff --git a/Gemfile b/Gemfile | |
| @@ -36,3 +36,23 @@ 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 | |
| +\ No newline at end of file | |
| diff --git a/Gemfile.lock b/Gemfile.lock | |
| @@ -45,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.5) | |
| activerecord (>= 3.2) | |
| @@ -59,6 +63,15 @@ GEM | |
| sass (>= 3.2.19) | |
| breadcrumbs_on_rails (2.3.0) | |
| 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.6) | |
| + 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) | |
| @@ -66,20 +79,60 @@ GEM | |
| coffee-script-source | |
| execjs | |
| coffee-script-source (1.9.1.1) | |
| + 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.5.2) | |
| + 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.8) | |
| ffi-compiler (0.1.3) | |
| ffi (>= 1.0.0) | |
| rake | |
| font-awesome-rails (4.3.0.0) | |
| railties (>= 3.2, < 5.0) | |
| + formatador (0.2.5) | |
| formtastic (3.1.3) | |
| actionpack (>= 3.2.13) | |
| formtastic-bootstrap (3.1.0) | |
| 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.4.0) | |
| + em-websocket (~> 0.5) | |
| + guard (~> 2.8) | |
| + 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-rails (3.1.2) | |
| railties (>= 3.0, < 5.0) | |
| @@ -87,15 +140,33 @@ GEM | |
| json (1.8.3) | |
| kgio (2.9.3) | |
| kissfft (0.0.2) | |
| + launchy (2.4.3) | |
| + addressable (~> 2.3) | |
| libv8 (3.16.14.7) | |
| + listen (3.0.3) | |
| + 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.6.1) | |
| + mini_portile (0.6.2) | |
| minitest (5.7.0) | |
| multi_json (1.11.0) | |
| + nenv (0.2.0) | |
| + nokogiri (1.6.6.2) | |
| + mini_portile (~> 0.6.0) | |
| + notiffany (0.0.8) | |
| + nenv (~> 0.1) | |
| + shellany (~> 0.0) | |
| pg (0.18.2) | |
| 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.3) | |
| rack-test (0.6.3) | |
| @@ -112,6 +183,7 @@ GEM | |
| sprockets-rails (~> 2.0) | |
| rails-settings-cached (0.4.1) | |
| rails (>= 4.0.0) | |
| + rails_layout (1.0.26) | |
| railties (4.1.10) | |
| actionpack (= 4.1.10) | |
| activesupport (= 4.1.10) | |
| @@ -119,9 +191,34 @@ GEM | |
| thor (>= 0.18.1, < 2.0) | |
| raindrops (0.13.0) | |
| rake (10.4.2) | |
| + rb-fsevent (0.9.6) | |
| + rb-inotify (0.9.5) | |
| + ffi (>= 0.5.0) | |
| ref (1.0.5) | |
| request_store (1.1.0) | |
| rex (2.0.8) | |
| + rspec (3.3.0) | |
| + rspec-core (~> 3.3.0) | |
| + rspec-expectations (~> 3.3.0) | |
| + rspec-mocks (~> 3.3.0) | |
| + rspec-core (3.3.2) | |
| + rspec-support (~> 3.3.0) | |
| + rspec-expectations (3.3.1) | |
| + diff-lcs (>= 1.2.0, < 2.0) | |
| + rspec-support (~> 3.3.0) | |
| + rspec-mocks (3.3.2) | |
| + diff-lcs (>= 1.2.0, < 2.0) | |
| + rspec-support (~> 3.3.0) | |
| + rspec-rails (3.3.3) | |
| + actionpack (>= 3.0, < 4.3) | |
| + activesupport (>= 3.0, < 4.3) | |
| + railties (>= 3.0, < 4.3) | |
| + rspec-core (~> 3.3.0) | |
| + rspec-expectations (~> 3.3.0) | |
| + rspec-mocks (~> 3.3.0) | |
| + rspec-support (~> 3.3.0) | |
| + rspec-support (3.3.0) | |
| + rubyzip (1.1.7) | |
| sass (3.2.19) | |
| sass-rails (4.0.5) | |
| railties (>= 4.0.0, < 5.0) | |
| @@ -131,6 +228,15 @@ GEM | |
| scrypt (1.2.1) | |
| 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.3) | |
| hike (~> 1.2) | |
| multi_json (~> 1.0) | |
| @@ -155,35 +261,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) | |
| + 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/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,3 +1,17 @@ | |
| +# == 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 | |
| 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/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/users.rb b/spec/factories/users.rb | |
| @@ -0,0 +1,31 @@ | |
| +# == 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 | |
| + | |
| + end | |
| + | |
| +end | |
| diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb | |
| @@ -0,0 +1,30 @@ | |
| +# == 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 | |
| + pending "add some examples to (or delete) #{__FILE__}" | |
| +end | |
| diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb | |
| @@ -0,0 +1,52 @@ | |
| +# 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| | |
| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures | |
| + config.fixture_path = "#{::Rails.root}/spec/fixtures" | |
| + | |
| + # If you're not using ActiveRecord, or you'd prefer not to run each of your | |
| + # examples within a transaction, remove the following line or assign false | |
| + # instead of true. | |
| + config.use_transactional_fixtures = true | |
| + | |
| + # RSpec Rails can automatically mix in different behaviours to your tests | |
| + # based on their file location, for example enabling you to call `get` and | |
| + # `post` in specs under `spec/controllers`. | |
| + # | |
| + # You can disable this behaviour by removing the line below, and instead | |
| + # 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 as in | |
| + # 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 |