Skip to content

Commit

Permalink
Fix travis spec failure
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbeales committed Apr 16, 2018
1 parent 0c51589 commit 62a9e24
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
10 changes: 9 additions & 1 deletion .overcommit.yml
Expand Up @@ -12,6 +12,15 @@
verify_signatures: false

PreCommit:
ALL:
problem_on_unmodified_line: warn
exclude: &default_excludes
- 'node_modules/**/*'
- 'vendor/**/*'
- 'db/migrate/*'
MyHook:
exclude:
- *default_excludes
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
Expand Down Expand Up @@ -40,4 +49,3 @@ CommitMsg:
PrePush:
RSpec:
enabled: true

4 changes: 4 additions & 0 deletions Rakefile
Expand Up @@ -2,6 +2,7 @@

require 'sinatra/activerecord'
require 'sinatra/activerecord/rake'
require 'pg_search'

# Heroku advises us to wrap Rspec tasks in a rescue block so rake does not throw error in production
begin
Expand All @@ -17,3 +18,6 @@ Dir.glob('lib/tasks/*.rake').each { |r| load r }
require 'bundler/audit/task'
Bundler::Audit::Task.new
task default: 'bundle:audit' # enable Travis CI to run a check for security vulnerabilities

# PgSearch index rebuild tasks
load "pg_search/tasks.rb"
4 changes: 3 additions & 1 deletion app/models/study_participant.rb
Expand Up @@ -22,12 +22,14 @@ def to_s
# id :integer not null, primary key
# participant_id :integer not null
# study_id :integer not null
# subject_number :string
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_by_participant_study (participant_id,study_id) UNIQUE
# index_participant_study (participant_id,study_id) UNIQUE
# index_study_participants_on_participant_id (participant_id)
# index_study_participants_on_study_id (study_id)
# index_study_subject_number (study_id, subject_number)
#
4 changes: 3 additions & 1 deletion db/migrate/20180318125505_create_study_participants.rb
Expand Up @@ -6,9 +6,11 @@ def change
create_table :study_participants do |t|
t.references :participant, null: false, foreign_key: true
t.references :study, null: false, foreign_key: true
t.string :subject_number, null: true
t.timestamps null: false, default: -> { 'CURRENT_TIMESTAMP' }
end

add_index :study_participants, %i[participant_id study_id], unique: true, name: 'index_by_participant_study'
add_index :study_participants, %i[participant_id study_id], unique: true, name: 'index_participant_study'
add_index :study_participants, %i[study_id subject_number], name: 'index_study_subject_number'
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Expand Up @@ -246,10 +246,12 @@
create_table "study_participants", force: :cascade do |t|
t.bigint "participant_id", null: false
t.bigint "study_id", null: false
t.string "subject_number"
t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.index ["participant_id", "study_id"], name: "index_by_participant_study", unique: true
t.index ["participant_id", "study_id"], name: "index_participant_study", unique: true
t.index ["participant_id"], name: "index_study_participants_on_participant_id"
t.index ["study_id", "subject_number"], name: "index_study_subject_number"
t.index ["study_id"], name: "index_study_participants_on_study_id"
end

Expand Down
6 changes: 3 additions & 3 deletions spec/models/item_spec.rb
Expand Up @@ -85,9 +85,9 @@
end

describe '#discard' do
instrument2 = Instrument.find_by(name: AppConstants::DEFAULT_INSTRUMENT)
item2 = Item.find_or_create_by! name: 'Item 2', instrument: instrument2,
item_type: 'radiogroup', title: 'abc'
instrument2 = Instrument.find_or_initialize_by(name: AppConstants::DEFAULT_INSTRUMENT)
item2 = Item.find_or_initialize_by name: 'Item 2', instrument: instrument2,
item_type: 'radiogroup', title: 'abc'
include_examples 'discards', item2
end
end

0 comments on commit 62a9e24

Please sign in to comment.