Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored associated survey spec #308

Merged
merged 1 commit into from
Mar 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 10 additions & 12 deletions spec/models/associated_survey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,19 @@
require 'rails_helper'

RSpec.describe AssociatedSurvey do
let!(:institution) { create(:institution, name: 'Medical University of South Carolina', order: 1, abbreviation: 'MUSC', is_available: 1)}
let!(:provider) { create(:provider, parent_id:institution.id,name: 'South Carolina Clinical and Translational Institute (SCTR)',order: 1,css_class: 'blue-provider',
abbreviation: 'SCTR1',process_ssrs: 0,is_available: 1)}
let!(:program) { create(:program, type:'Program',parent_id:provider.id,name:'Office of Biomedical Informatics',order:1,
abbreviation:'Informatics',process_ssrs: 0, is_available: 1)}
let!(:core) { create(:core, parent_id: program.id)}
let!(:service) { create(:service, organization_id: program.id, name: 'One Time Fee') }
let!(:survey) { create(:survey, title: "System Satisfaction survey", description: nil, access_code: "system-satisfaction-survey", reference_identifier: nil,
data_export_identifier: nil, common_namespace: nil, common_identifier: nil, active_at: nil, inactive_at: nil, css_url: nil,
custom_class: nil, created_at: "2013-07-02 14:40:23", updated_at: "2013-07-02 14:40:23", display_order: 0, api_id: "4137bedf-40db-43e9-a411-932a5f6d77b7",
survey_version: 0) }

it "should create an associated survey" do
service = build_stubbed(:service)
survey = create(:survey)

service.associated_surveys.create survey_id: survey.id

expect(service.associated_surveys.size).to eq(1)
end

it "should not allow you to associate the same survey version multiple times" do
service = create(:service)
survey = create(:survey)

service.associated_surveys.create survey_id: survey.id
service.associated_surveys.create survey_id: survey.id

Expand All @@ -47,6 +42,8 @@
end

it "should not allow you to create an associated survey without valid attributes" do
service = create(:service)
survey = create(:survey)

#should not
service.associated_surveys.create survey_id: nil
Expand All @@ -64,3 +61,4 @@
expect(AssociatedSurvey.count).to eq(1)
end
end