parent
1a18837fa2
commit
a2caf42fee
@ -1,224 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe AttemptsController, type: :controller do
|
||||
let(:valid_session) { {} }
|
||||
|
||||
let!(:recipients) { create_recipients(school, 2) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:category) { Legacy::Category.create(name: 'Test Category') }
|
||||
let!(:questions) { create_questions(3, category) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let(:schedule) do
|
||||
Schedule.create(name: 'Test Schedule', question_list:, recipient_list:)
|
||||
end
|
||||
let(:school) { Legacy::School.create!(name: 'School') }
|
||||
|
||||
let(:recipient_schedule) do
|
||||
RecipientSchedule.create(recipient: recipients.first, schedule:, next_attempt_at: Time.now)
|
||||
end
|
||||
let(:recipient_schedule2) do
|
||||
RecipientSchedule.create(recipient: recipients.last, schedule:, next_attempt_at: Time.now)
|
||||
end
|
||||
|
||||
let!(:first_attempt) do
|
||||
Attempt.create(
|
||||
schedule:,
|
||||
recipient: recipients.first,
|
||||
recipient_schedule:,
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
end
|
||||
let!(:attempt) do
|
||||
Attempt.create(
|
||||
schedule:,
|
||||
recipient: recipients.first,
|
||||
recipient_schedule:,
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
end
|
||||
let!(:attempt2) do
|
||||
Attempt.create(
|
||||
schedule:,
|
||||
recipient: recipients.last,
|
||||
recipient_schedule: recipient_schedule2,
|
||||
question: questions.first,
|
||||
sent_at: Time.new
|
||||
)
|
||||
end
|
||||
|
||||
describe 'POST #twilio' do
|
||||
context 'with valid params' do
|
||||
let(:twilio_attributes) do
|
||||
{ 'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf', 'AccountSid' => 'wefiuwhefuwehfuwefinwefw',
|
||||
'MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf', 'From' => '+0000000000', 'To' => '2223334444', 'Body' => '3', 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
before :each do
|
||||
post :twilio, params: twilio_attributes
|
||||
end
|
||||
|
||||
it 'creates the first attempt with response for the question' do
|
||||
expect(attempt.question.attempts.for_school(school).with_answer.count).to eq(1)
|
||||
end
|
||||
|
||||
it 'updates the last attempt by recipient phone number' do
|
||||
attempt.reload
|
||||
expect(attempt.answer_index).to eq(3)
|
||||
expect(attempt.twilio_details).to eq(twilio_attributes.with_indifferent_access.to_yaml)
|
||||
expect(attempt.responded_at).to be_present
|
||||
|
||||
expect(first_attempt.answer_index).to be_nil
|
||||
expect(first_attempt.twilio_details).to be_nil
|
||||
expect(first_attempt.responded_at).to be_nil
|
||||
end
|
||||
|
||||
it 'sends back a message' do
|
||||
expect(response.body).to eq "We've registered your response of \"Option 0:3 C\". You are the first person to respond to this question. Once more people have responded you will be able to see all responses at: http://test.host/schools/school/categories/test-category"
|
||||
end
|
||||
|
||||
context 'with second response' do
|
||||
let(:twilio_attributes2) do
|
||||
{ 'MessageSid' => 'fwefwefewfewfasfsdfdf', 'AccountSid' => 'wefwegdbvcbrtnrn',
|
||||
'MessagingServiceSid' => 'dfvdfvegbdfb', 'From' => '+1111111111', 'To' => '2223334444', 'Body' => '4', 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
before :each do
|
||||
post :twilio, params: twilio_attributes2
|
||||
end
|
||||
|
||||
it 'updates the second attempt with response for the school' do
|
||||
expect(attempt.question.attempts.for_school(school).with_answer.count).to eq(2)
|
||||
end
|
||||
|
||||
it 'updates the attempt from the second recipient' do
|
||||
attempt2.reload
|
||||
expect(attempt2.answer_index).to eq(4)
|
||||
expect(attempt2.twilio_details).to eq(twilio_attributes2.with_indifferent_access.to_yaml)
|
||||
expect(attempt2.responded_at).to be_present
|
||||
end
|
||||
|
||||
it 'sends back a message' do
|
||||
expect(response.body).to eq "We've registered your response of \"Option 0:3 D\". 2 people have responded to this question so far. To see all responses visit: http://test.host/schools/school/categories/test-category"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%w[stOp cANcel QuIt no].each do |command|
|
||||
context "with #{command} command" do
|
||||
let(:twilio_attributes) do
|
||||
{ 'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf', 'AccountSid' => 'wefiuwhefuwehfuwefinwefw',
|
||||
'MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf', 'From' => '+0000000000', 'To' => '2223334444', 'Body' => command, 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
it 'updates the last attempt by recipient phone number' do
|
||||
post :twilio, params: twilio_attributes
|
||||
attempt.reload
|
||||
expect(attempt.answer_index).to be_nil
|
||||
expect(attempt.twilio_details).to eq(twilio_attributes.with_indifferent_access.to_yaml)
|
||||
expect(attempt.recipient).to be_opted_out
|
||||
end
|
||||
|
||||
it 'sends back a message' do
|
||||
post :twilio, params: twilio_attributes
|
||||
expect(response.body).to eq('Thank you, you have been opted out of these messages and will no longer receive them.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%w[staRt reSUme rEstaRt Yes go].each do |command|
|
||||
context "with #{command} command" do
|
||||
before :each do
|
||||
attempt.recipient.update(opted_out: true)
|
||||
end
|
||||
|
||||
let(:twilio_attributes) do
|
||||
{ 'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf', 'AccountSid' => 'wefiuwhefuwehfuwefinwefw',
|
||||
'MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf', 'From' => '+0000000000', 'To' => '2223334444', 'Body' => command, 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
it 'updates the last attempt by recipient phone number' do
|
||||
expect(attempt.recipient).to be_opted_out
|
||||
post :twilio, params: twilio_attributes
|
||||
attempt.reload
|
||||
expect(attempt.answer_index).to be_nil
|
||||
expect(attempt.twilio_details).to eq(twilio_attributes.with_indifferent_access.to_yaml)
|
||||
expect(attempt.recipient).to_not be_opted_out
|
||||
end
|
||||
|
||||
it 'sends back a message' do
|
||||
post :twilio, params: twilio_attributes
|
||||
expect(response.body).to eq('Thank you, you will now begin receiving messages again.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
['skip', 'i dont know', "i don't know", 'next'].each do |command|
|
||||
context "with #{command} command" do
|
||||
let(:twilio_skip_attributes) do
|
||||
{ 'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf', 'AccountSid' => 'wefiuwhefuwehfuwefinwefw',
|
||||
'MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf', 'From' => '+0000000000', 'To' => '2223334444', 'Body' => command, 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
it 'updates the last attempt by recipient phone number' do
|
||||
post :twilio, params: twilio_skip_attributes
|
||||
attempt.reload
|
||||
expect(attempt.answer_index).to be_nil
|
||||
expect(attempt.responded_at).to be_present
|
||||
expect(attempt.twilio_details).to eq(twilio_skip_attributes.with_indifferent_access.to_yaml)
|
||||
expect(attempt.recipient).to_not be_opted_out
|
||||
|
||||
school_attempts = attempt.question.attempts.for_school(school)
|
||||
expect(school_attempts.with_answer.count).to eq(0)
|
||||
expect(school_attempts.with_no_answer.count).to eq(3)
|
||||
expect(school_attempts.not_yet_responded.count).to eq(2)
|
||||
end
|
||||
|
||||
it 'sends back a message' do
|
||||
post :twilio, params: twilio_skip_attributes
|
||||
expect(response.body).to eq('Thank you, this question has been skipped.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #twilio with response to repeated question' do
|
||||
context 'with valid params' do
|
||||
let!(:recent_first_attempt) do
|
||||
first_attempt.update(sent_at: Time.new)
|
||||
return first_attempt
|
||||
end
|
||||
|
||||
let(:twilio_attributes) do
|
||||
{ 'MessageSid' => 'ewuefhwieuhfweiuhfewiuhf', 'AccountSid' => 'wefiuwhefuwehfuwefinwefw',
|
||||
'MessagingServiceSid' => 'efwneufhwuefhweiufhiuewhf', 'From' => '+0000000000', 'To' => '2223334444', 'Body' => '2', 'NumMedia' => '0' }
|
||||
end
|
||||
|
||||
before :each do
|
||||
post :twilio, params: twilio_attributes
|
||||
end
|
||||
|
||||
it 'updates the first attempt (that now has the most recent sent_at)' do
|
||||
recent_first_attempt.reload
|
||||
expect(recent_first_attempt.answer_index).to eq(2)
|
||||
expect(recent_first_attempt.twilio_details).to eq(twilio_attributes.with_indifferent_access.to_yaml)
|
||||
expect(recent_first_attempt.responded_at).to be_present
|
||||
|
||||
expect(attempt.answer_index).to be_nil
|
||||
expect(attempt.twilio_details).to be_nil
|
||||
expect(attempt.responded_at).to be_nil
|
||||
|
||||
expect(recent_first_attempt.id).to be < attempt.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,171 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe Legacy::CategoriesController, type: :controller do
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Category. As you add validations to Category, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{ name: 'Category', external_id: 'A' }
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ name: '' }
|
||||
end
|
||||
|
||||
let(:district) do
|
||||
Legacy::District.create! name: 'District'
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# CategoriesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all categories as @categories' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:categories)).to eq([category])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested school and category as @school and @category' do
|
||||
school = Legacy::School.create! name: 'School', district: district
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
get :show, params: { school_id: school.id, id: category.to_param }, session: valid_session
|
||||
expect(assigns(:category)).to eq(category)
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
|
||||
it 'redirects to root_path if school is not provided' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
get :show, params: { id: category.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new category as @category' do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:category)).to be_a_new(Legacy::Category)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested category as @category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
get :edit, params: { id: category.to_param }, session: valid_session
|
||||
expect(assigns(:category)).to eq(category)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new Category' do
|
||||
expect do
|
||||
post :create, params: { category: valid_attributes }, session: valid_session
|
||||
end.to change(Legacy::Category, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created category as @category' do
|
||||
post :create, params: { category: valid_attributes }, session: valid_session
|
||||
expect(assigns(:category)).to be_a(Legacy::Category)
|
||||
expect(assigns(:category)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created category' do
|
||||
post :create, params: { category: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(Legacy::Category.last)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved category as @category' do
|
||||
post :create, params: { category: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:category)).to be_a_new(Legacy::Category)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { category: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ name: 'Category 2' }
|
||||
end
|
||||
|
||||
it 'updates the requested category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
put :update, params: { id: category.to_param, category: new_attributes }, session: valid_session
|
||||
category.reload
|
||||
expect(category.name).to eq('Category 2')
|
||||
end
|
||||
|
||||
it 'assigns the requested category as @category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
put :update, params: { id: category.to_param, category: valid_attributes }, session: valid_session
|
||||
expect(assigns(:category)).to eq(category)
|
||||
end
|
||||
|
||||
it 'redirects to the category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
put :update, params: { id: category.to_param, category: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(category)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the category as @category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
put :update, params: { id: category.to_param, category: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:category)).to eq(category)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
put :update, params: { id: category.to_param, category: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested category' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { id: category.to_param }, session: valid_session
|
||||
end.to change(Legacy::Category, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the categories list' do
|
||||
category = Legacy::Category.create! valid_attributes
|
||||
delete :destroy, params: { id: category.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_categories_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,140 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe DistrictsController, type: :controller do
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# District. As you add validations to District, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{ name: 'Milford' }
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ name: '' }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# DistrictsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all districts as @districts' do
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:districts)).to eq(District.all.alphabetic)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested district as @district' do
|
||||
district = District.create! valid_attributes
|
||||
get :show, params: { id: district.to_param }, session: valid_session
|
||||
expect(assigns(:district)).to eq(district)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new district as @district' do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:district)).to be_a_new(District)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested district as @district' do
|
||||
district = District.create! valid_attributes
|
||||
get :edit, params: { id: district.to_param }, session: valid_session
|
||||
expect(assigns(:district)).to eq(district)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new District' do
|
||||
expect do
|
||||
post :create, params: { district: valid_attributes }, session: valid_session
|
||||
end.to change(District, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created district as @district' do
|
||||
post :create, params: { district: valid_attributes }, session: valid_session
|
||||
expect(assigns(:district)).to be_a(District)
|
||||
expect(assigns(:district)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created district' do
|
||||
post :create, params: { district: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(District.last)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved district as @district' do
|
||||
post :create, params: { district: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:district)).to be_a_new(District)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { district: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ name: 'New District' }
|
||||
end
|
||||
|
||||
it 'updates the requested district' do
|
||||
district = District.create! valid_attributes
|
||||
put :update, params: { id: district.to_param, district: new_attributes }, session: valid_session
|
||||
district.reload
|
||||
expect(district.name).to eq('New District')
|
||||
end
|
||||
|
||||
it 'assigns the requested district as @district' do
|
||||
district = District.create! valid_attributes
|
||||
put :update, params: { id: district.to_param, district: valid_attributes }, session: valid_session
|
||||
expect(assigns(:district)).to eq(district)
|
||||
end
|
||||
|
||||
it 'redirects to the district' do
|
||||
district = District.create! valid_attributes
|
||||
put :update, params: { id: district.to_param, district: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(district)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the district as @district' do
|
||||
district = District.create! valid_attributes
|
||||
put :update, params: { id: district.to_param, district: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:district)).to eq(district)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
district = District.create! valid_attributes
|
||||
put :update, params: { id: district.to_param, district: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested district' do
|
||||
district = District.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { id: district.to_param }, session: valid_session
|
||||
end.to change(District, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the districts list' do
|
||||
district = District.create! valid_attributes
|
||||
delete :destroy, params: { id: district.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(districts_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,159 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe QuestionListsController, type: :controller do
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# QuestionList. As you add validations to QuestionList, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{ name: 'Questions for Parents', question_id_array: ['', '1', '2', '3'] }
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ question_id_array: [''] }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# QuestionListsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all question_lists as @question_lists' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:question_lists)).to eq([question_list])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested question_list as @question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
get :show, params: { id: question_list.to_param }, session: valid_session
|
||||
expect(assigns(:question_list)).to eq(question_list)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new question_list as @question_list' do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:question_list)).to be_a_new(QuestionList)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested question_list as @question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
get :edit, params: { id: question_list.to_param }, session: valid_session
|
||||
expect(assigns(:question_list)).to eq(question_list)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new QuestionList' do
|
||||
expect do
|
||||
post :create, params: { question_list: valid_attributes }, session: valid_session
|
||||
end.to change(QuestionList, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created question_list as @question_list' do
|
||||
post :create, params: { question_list: valid_attributes }, session: valid_session
|
||||
expect(assigns(:question_list)).to be_a(QuestionList)
|
||||
expect(assigns(:question_list)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created question_list' do
|
||||
post :create, params: { question_list: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(QuestionList.last)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved question_list as @question_list' do
|
||||
post :create, params: { question_list: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:question_list)).to be_a_new(QuestionList)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { question_list: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ question_id_array: ['', '2', '3'] }
|
||||
end
|
||||
|
||||
it 'updates the requested question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
put :update, params: { id: question_list.to_param, question_list: new_attributes }, session: valid_session
|
||||
question_list.reload
|
||||
expect(question_list.question_ids).to eq('2,3')
|
||||
end
|
||||
|
||||
it 'assigns the requested question_list as @question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
put :update, params: { id: question_list.to_param, question_list: valid_attributes }, session: valid_session
|
||||
expect(assigns(:question_list)).to eq(question_list)
|
||||
end
|
||||
|
||||
it 'redirects to the question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
put :update, params: { id: question_list.to_param, question_list: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(question_list)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the question_list as @question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
put :update, params: { id: question_list.to_param, question_list: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:question_list)).to eq(question_list)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
put :update, params: { id: question_list.to_param, question_list: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested question_list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { id: question_list.to_param }, session: valid_session
|
||||
end.to change(QuestionList, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the question_lists list' do
|
||||
question_list = QuestionList.create! valid_attributes
|
||||
delete :destroy, params: { id: question_list.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_question_lists_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,175 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe QuestionsController, type: :controller do
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Question. As you add validations to Question, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let!(:user) { User.create(email: 'test@test.com', password: '123456') }
|
||||
let(:category) { Legacy::Category.create!(name: 'Category') }
|
||||
let(:valid_attributes) do
|
||||
{
|
||||
text: 'Question',
|
||||
option1: 'option1',
|
||||
option2: 'option2',
|
||||
option3: 'option3',
|
||||
option4: 'option4',
|
||||
option5: 'option5',
|
||||
category_id: category.id
|
||||
}
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ text: '' }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# QuestionsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
before :each do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all questions as @questions' do
|
||||
question = Question.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:questions)).to eq([question])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested question as @question' do
|
||||
school = School.create!(name: 'School')
|
||||
question = Question.create! valid_attributes
|
||||
get :show, params: { school_id: school.id, id: question.to_param }, session: valid_session
|
||||
expect(assigns(:question)).to eq(question)
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new question as @question' do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:question)).to be_a_new(Question)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested question as @question' do
|
||||
question = Question.create! valid_attributes
|
||||
get :edit, params: { id: question.to_param }, session: valid_session
|
||||
expect(assigns(:question)).to eq(question)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new Question' do
|
||||
expect do
|
||||
post :create, params: { question: valid_attributes }, session: valid_session
|
||||
end.to change(Question, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created question as @question' do
|
||||
post :create, params: { question: valid_attributes }, session: valid_session
|
||||
expect(assigns(:question)).to be_a(Question)
|
||||
expect(assigns(:question)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created question' do
|
||||
post :create, params: { question: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(Question.last)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved question as @question' do
|
||||
post :create, params: { question: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:question)).to be_a_new(Question)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { question: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ text: 'Question2' }
|
||||
end
|
||||
|
||||
it 'updates the requested question' do
|
||||
question = Question.create! valid_attributes
|
||||
put :update, params: { id: question.to_param, question: new_attributes }, session: valid_session
|
||||
question.reload
|
||||
expect(question.text).to eq('Question2')
|
||||
end
|
||||
|
||||
it 'assigns the requested question as @question' do
|
||||
question = Question.create! valid_attributes
|
||||
put :update, params: { id: question.to_param, question: valid_attributes }, session: valid_session
|
||||
expect(assigns(:question)).to eq(question)
|
||||
end
|
||||
|
||||
it 'redirects to the question' do
|
||||
question = Question.create! valid_attributes
|
||||
put :update, params: { id: question.to_param, question: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(question)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the question as @question' do
|
||||
question = Question.create! valid_attributes
|
||||
put :update, params: { id: question.to_param, question: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:question)).to eq(question)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
question = Question.create! valid_attributes
|
||||
put :update, params: { id: question.to_param, question: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested question' do
|
||||
question = Question.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { id: question.to_param }, session: valid_session
|
||||
end.to change(Question, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the questions list' do
|
||||
question = Question.create! valid_attributes
|
||||
delete :destroy, params: { id: question.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_questions_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,185 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe RecipientListsController, type: :controller do
|
||||
let!(:user) { User.create(email: 'test@test.com', password: '123456') }
|
||||
let(:school) { School.create!(name: 'School') }
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# RecipientList. As you add validations to RecipientList, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{
|
||||
school_id: school.id,
|
||||
recipient_id_array: ['', '1', '2', '3'],
|
||||
name: 'Parents',
|
||||
description: 'List of parents.'
|
||||
}
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ school_id: school.id, name: '' }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# RecipientListsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
before :each do
|
||||
user.user_schools.create(school:)
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all recipient_lists as @recipient_lists' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
get :index, params: { school_id: school.to_param }, session: valid_session
|
||||
expect(assigns(:recipient_lists)).to eq([recipient_list])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested recipient_list as @recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
get :show, params: { school_id: school.to_param, id: recipient_list.to_param }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to eq(recipient_list)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new recipient_list as @recipient_list' do
|
||||
get :new, params: { school_id: school.to_param }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to be_a_new(RecipientList)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested recipient_list as @recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
get :edit, params: { school_id: school.to_param, id: recipient_list.to_param }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to eq(recipient_list)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new RecipientList' do
|
||||
expect do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: valid_attributes },
|
||||
session: valid_session
|
||||
end.to change(RecipientList, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created recipient_list as @recipient_list' do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: valid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to be_a(RecipientList)
|
||||
expect(assigns(:recipient_list)).to be_persisted
|
||||
end
|
||||
|
||||
it 'stores recipient_ids properly' do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: valid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient_list).recipient_ids).to eq('1,2,3')
|
||||
end
|
||||
|
||||
it 'redirects to the created recipient_list' do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_school_legacy_recipient_list_path(school, RecipientList.last))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved recipient_list as @recipient_list' do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(assigns(:recipient_list)).to be_a_new(RecipientList)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { school_id: school.to_param, recipient_list: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ recipient_id_array: ['', '3', '4', '5'] }
|
||||
end
|
||||
|
||||
it 'updates the requested recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
put :update,
|
||||
params: { school_id: school.to_param, id: recipient_list.to_param, recipient_list: new_attributes }, session: valid_session
|
||||
recipient_list.reload
|
||||
expect(recipient_list.recipient_ids).to eq('3,4,5')
|
||||
end
|
||||
|
||||
it 'assigns the requested recipient_list as @recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
put :update,
|
||||
params: { school_id: school.to_param, id: recipient_list.to_param, recipient_list: valid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to eq(recipient_list)
|
||||
end
|
||||
|
||||
it 'redirects to the recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
put :update,
|
||||
params: { school_id: school.to_param, id: recipient_list.to_param, recipient_list: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_school_legacy_recipient_list_url(school, recipient_list))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the recipient_list as @recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
put :update,
|
||||
params: { school_id: school.to_param, id: recipient_list.to_param, recipient_list: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient_list)).to eq(recipient_list)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
put :update,
|
||||
params: { school_id: school.to_param, id: recipient_list.to_param, recipient_list: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested recipient_list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { school_id: school.to_param, id: recipient_list.to_param }, session: valid_session
|
||||
end.to change(RecipientList, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the recipient_lists list' do
|
||||
recipient_list = RecipientList.create! valid_attributes
|
||||
delete :destroy, params: { school_id: school.to_param, id: recipient_list.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(school)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,175 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe RecipientsController, type: :controller do
|
||||
let!(:user) { User.create(email: 'test@test.com', password: '123456') }
|
||||
let(:school) { School.create!(name: 'School') }
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Recipient. As you add validations to Recipient, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{
|
||||
name: 'Recipient Name',
|
||||
phone: '111-222-3333',
|
||||
school_id: school.id
|
||||
}
|
||||
end
|
||||
|
||||
let(:invalid_attributes) { { name: '', phone: '111-222-3333' } }
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# RecipientsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
before :each do
|
||||
user.user_schools.create(school:)
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
it 'assigns all recipients as @recipients' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
get :index, params: { school_id: school.to_param }, session: valid_session
|
||||
expect(assigns(:recipients)).to eq([recipient])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested recipient as @recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
get :show, params: { school_id: school.to_param, id: recipient.to_param }, session: valid_session
|
||||
expect(assigns(:recipient)).to eq(recipient)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new recipient as @recipient' do
|
||||
get :new, params: { school_id: school.id }, session: valid_session
|
||||
expect(assigns(:recipient)).to be_a_new(Recipient)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested recipient as @recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
get :edit, params: { school_id: school.to_param, id: recipient.to_param }, session: valid_session
|
||||
expect(assigns(:recipient)).to eq(recipient)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new Recipient' do
|
||||
expect do
|
||||
post :create, params: { school_id: school.to_param, recipient: valid_attributes }, session: valid_session
|
||||
end.to change(Recipient, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created recipient as @recipient' do
|
||||
post :create, params: { school_id: school.to_param, recipient: valid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient)).to be_a(Recipient)
|
||||
expect(assigns(:recipient)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created recipient' do
|
||||
post :create, params: { school_id: school.to_param, recipient: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to(legacy_school_legacy_recipient_path(school, Recipient.last))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved recipient as @recipient' do
|
||||
post :create, params: { school_id: school.to_param, recipient: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:recipient)).to be_a_new(Recipient)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { school_id: school.to_param, recipient: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ name: 'New Name' }
|
||||
end
|
||||
|
||||
it 'updates the requested recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
put :update, params: { school_id: school.to_param, id: recipient.to_param, recipient: new_attributes },
|
||||
session: valid_session
|
||||
recipient.reload
|
||||
expect(recipient.name).to eq('New Name')
|
||||
expect(recipient.phone).to eq('111-222-3333')
|
||||
end
|
||||
|
||||
it 'assigns the requested recipient as @recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
put :update, params: { school_id: school.to_param, id: recipient.to_param, recipient: valid_attributes },
|
||||
session: valid_session
|
||||
expect(assigns(:recipient)).to eq(recipient)
|
||||
end
|
||||
|
||||
it 'redirects to the recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
put :update, params: { school_id: school.to_param, id: recipient.to_param, recipient: valid_attributes },
|
||||
session: valid_session
|
||||
expect(response).to redirect_to(legacy_school_legacy_recipient_url(school, recipient))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the recipient as @recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
put :update, params: { school_id: school.to_param, id: recipient.to_param, recipient: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(assigns(:recipient)).to eq(recipient)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
put :update, params: { school_id: school.to_param, id: recipient.to_param, recipient: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested recipient' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { school_id: school.to_param, id: recipient.to_param }, session: valid_session
|
||||
end.to change(Recipient, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the recipients list' do
|
||||
recipient = Recipient.create! valid_attributes
|
||||
delete :destroy, params: { school_id: school.to_param, id: recipient.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(school)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,187 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe SchedulesController, type: :controller do
|
||||
let!(:user) { User.create(email: 'test@test.com', password: '123456') }
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipients) { create_recipients(school, 3) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:questions) { create_questions(3) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Schedule. As you add validations to Schedule, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{
|
||||
school_id: school.id,
|
||||
recipient_list_id: recipient_list.id,
|
||||
question_list_id: question_list.id,
|
||||
name: 'Parents Schedule',
|
||||
description: 'Schedule for parent questions',
|
||||
time: (8 * 60)
|
||||
}
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ name: '' }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# SchedulesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
before :each do
|
||||
user.user_schools.create(school:)
|
||||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested schedule as @schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
get :show, params: { school_id: school.id, id: schedule.to_param }, session: valid_session
|
||||
expect(assigns(:schedule)).to eq(schedule)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new schedule as @schedule' do
|
||||
get :new, params: { school_id: school.id }, session: valid_session
|
||||
expect(assigns(:schedule)).to be_a_new(Schedule)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested schedule as @schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
get :edit, params: { school_id: school.id, id: schedule.to_param }, session: valid_session
|
||||
expect(assigns(:schedule)).to eq(schedule)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'with valid params' do
|
||||
it 'creates a new Schedule' do
|
||||
expect do
|
||||
post :create, params: { school_id: school.id, schedule: valid_attributes }, session: valid_session
|
||||
end.to change(Schedule, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created schedule as @schedule' do
|
||||
post :create, params: { school_id: school.id, schedule: valid_attributes }, session: valid_session
|
||||
expect(assigns(:schedule)).to be_a(Schedule)
|
||||
expect(assigns(:schedule)).to be_persisted
|
||||
end
|
||||
|
||||
it "updates the schedule's time to UTC from EST" do
|
||||
post :create, params: { school_id: school.id, schedule: valid_attributes }, session: valid_session
|
||||
expect(assigns(:schedule)).to be_a(Schedule)
|
||||
expect(assigns(:schedule).time).to eq(60 * 12)
|
||||
end
|
||||
|
||||
it 'redirects to the created schedule' do
|
||||
post :create, params: { school_id: school.id, schedule: valid_attributes }, session: valid_session
|
||||
expect(response).to redirect_to([school, Schedule.last])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved schedule as @schedule' do
|
||||
post :create, params: { school_id: school.id, schedule: invalid_attributes }, session: valid_session
|
||||
expect(assigns(:schedule)).to be_a_new(Schedule)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { school_id: school.id, schedule: invalid_attributes }, session: valid_session
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ name: 'New Name' }
|
||||
end
|
||||
|
||||
it 'updates the requested schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
put :update, params: { school_id: school.id, id: schedule.to_param, schedule: new_attributes },
|
||||
session: valid_session
|
||||
schedule.reload
|
||||
expect(schedule.name).to eq('New Name')
|
||||
end
|
||||
|
||||
it 'assigns the requested schedule as @schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
put :update, params: { school_id: school.id, id: schedule.to_param, schedule: valid_attributes },
|
||||
session: valid_session
|
||||
expect(assigns(:schedule)).to eq(schedule)
|
||||
end
|
||||
|
||||
it 'redirects to the schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
put :update, params: { school_id: school.id, id: schedule.to_param, schedule: valid_attributes },
|
||||
session: valid_session
|
||||
expect(response).to redirect_to([school, schedule])
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the schedule as @schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
put :update, params: { school_id: school.id, id: schedule.to_param, schedule: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(assigns(:schedule)).to eq(schedule)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
put :update, params: { school_id: school.id, id: schedule.to_param, schedule: invalid_attributes },
|
||||
session: valid_session
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
it 'destroys the requested schedule' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
expect do
|
||||
delete :destroy, params: { school_id: school.id, id: schedule.to_param }, session: valid_session
|
||||
end.to change(Schedule, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the schedules list' do
|
||||
schedule = Schedule.create! valid_attributes
|
||||
delete :destroy, params: { school_id: school.id, id: schedule.to_param }, session: valid_session
|
||||
expect(response).to redirect_to(school)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,183 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
module Legacy
|
||||
RSpec.describe SchoolsController, type: :controller do
|
||||
let(:district) { District.create! name: 'District' }
|
||||
let!(:school) { School.create! name: 'school', district: }
|
||||
let!(:user) { User.create(email: 'test@example.com', password: '123456') }
|
||||
let!(:user_school) { user.user_schools.create(school:) }
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# School. As you add validations to School, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) do
|
||||
{ name: 'School', district: }
|
||||
end
|
||||
|
||||
let(:invalid_attributes) do
|
||||
{ name: '' }
|
||||
end
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# SchoolsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe 'GET #show' do
|
||||
it 'assigns the requested school as @school' do
|
||||
get :show, params: { id: school.to_param }, session: valid_session
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
it 'assigns a new school as @school' do
|
||||
sign_in user
|
||||
get :new, params: {}
|
||||
expect(assigns(:school)).to be_a_new(School)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
it 'assigns the requested school as @school' do
|
||||
sign_in user
|
||||
school = School.create! valid_attributes
|
||||
get :edit, params: { id: school.to_param }
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #admin' do
|
||||
it 'assigns the requested school as @school' do
|
||||
sign_in user
|
||||
get :admin, params: { school_id: school.to_param }
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
|
||||
it 'redirects if not logged in' do
|
||||
get :admin, params: { school_id: school.to_param }
|
||||
expect(response).to redirect_to(new_user_session_path)
|
||||
end
|
||||
|
||||
xit 'redirects if user is not associated with school' do
|
||||
another_user = User.create(email: 'test2@test.com', password: '123456')
|
||||
sign_in another_user
|
||||
|
||||
get :admin, params: { school_id: school.to_param }
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
before :each do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
context 'with valid params' do
|
||||
it 'creates a new School' do
|
||||
expect do
|
||||
post :create, params: { school: valid_attributes }
|
||||
end.to change(School, :count).by(1)
|
||||
end
|
||||
|
||||
it 'assigns a newly created school as @school' do
|
||||
post :create, params: { school: valid_attributes }
|
||||
expect(assigns(:school)).to be_a(School)
|
||||
expect(assigns(:school)).to be_persisted
|
||||
end
|
||||
|
||||
it 'redirects to the created school' do
|
||||
post :create, params: { school: valid_attributes }
|
||||
expect(response).to redirect_to(School.last)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns a newly created but unsaved school as @school' do
|
||||
post :create, params: { school: invalid_attributes }
|
||||
expect(assigns(:school)).to be_a_new(School)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: { school: invalid_attributes }
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
before :each do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
context 'with valid params' do
|
||||
let(:new_attributes) do
|
||||
{ name: 'New School' }
|
||||
end
|
||||
|
||||
it 'updates the requested school' do
|
||||
put :update, params: { id: school.to_param, school: new_attributes }
|
||||
school.reload
|
||||
expect(school.name).to eq('New School')
|
||||
end
|
||||
|
||||
it 'assigns the requested school as @school' do
|
||||
put :update, params: { id: school.to_param, school: valid_attributes }
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
|
||||
it 'redirects to the school' do
|
||||
put :update, params: { id: school.to_param, school: valid_attributes }
|
||||
expect(response).to redirect_to(school)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid params' do
|
||||
it 'assigns the school as @school' do
|
||||
put :update, params: { id: school.to_param, school: invalid_attributes }
|
||||
expect(assigns(:school)).to eq(school)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
put :update, params: { id: school.to_param, school: invalid_attributes }
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
before :each do
|
||||
sign_in user
|
||||
end
|
||||
|
||||
it 'destroys the requested school' do
|
||||
expect do
|
||||
delete :destroy, params: { id: school.to_param }
|
||||
end.to change(School, :count).by(-1)
|
||||
end
|
||||
|
||||
it 'redirects to the schools list' do
|
||||
delete :destroy, params: { id: school.to_param }
|
||||
expect(response).to redirect_to(legacy_schools_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,11 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe WelcomeController, type: :controller do
|
||||
describe 'GET #index' do
|
||||
it 'works' do
|
||||
get :index
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,115 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
describe Attempt, type: :model do
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipient) { school.recipients.create(name: 'name', phone: '1' * 9) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipient.id.to_s)
|
||||
end
|
||||
|
||||
let!(:category) { Category.create(name: 'Category') }
|
||||
let!(:question) { create_questions(1, category).first }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: question.id.to_s)
|
||||
end
|
||||
|
||||
let(:schedule) do
|
||||
Schedule.create!(name: 'Parent Schedule', recipient_list_id: recipient_list.id, question_list:)
|
||||
end
|
||||
|
||||
let(:recipient_schedule) do
|
||||
RecipientSchedule.create!(
|
||||
recipient:,
|
||||
schedule:,
|
||||
upcoming_question_ids: "#{question.id},3",
|
||||
attempted_question_ids: '2',
|
||||
last_attempt_at: 2.weeks.ago,
|
||||
next_attempt_at: Time.new
|
||||
)
|
||||
end
|
||||
|
||||
let!(:attempt) do
|
||||
recipient.attempts.create(
|
||||
schedule:,
|
||||
recipient_schedule:,
|
||||
question:
|
||||
)
|
||||
end
|
||||
|
||||
describe 'after_save' do
|
||||
let!(:school_categories) { SchoolCategory.for(attempt.recipient.school, attempt.question.category) }
|
||||
|
||||
xit 'creates the associated school_category' do
|
||||
expect(school_categories.count).to eq(1)
|
||||
expect(school_categories.first.attempt_count).to eq(1)
|
||||
expect(school_categories.first.response_count).to eq(0)
|
||||
expect(school_categories.first.answer_index_total).to eq(0)
|
||||
end
|
||||
|
||||
describe 'after_update' do
|
||||
before :each do
|
||||
attempt.update(answer_index: 4)
|
||||
end
|
||||
|
||||
xit 'updates associated school_categories' do
|
||||
expect(school_categories.count).to eq(1)
|
||||
expect(school_categories.first.attempt_count).to eq(1)
|
||||
expect(school_categories.first.response_count).to eq(1)
|
||||
expect(school_categories.first.answer_index_total).to eq(4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'counters' do
|
||||
it 'are updated when an attempt is created' do
|
||||
expect(recipient.attempts_count).to eq(1)
|
||||
expect(recipient.responses_count).to eq(0)
|
||||
end
|
||||
|
||||
it 'are updated when an attempt is destroyed' do
|
||||
attempt.destroy
|
||||
expect(recipient.attempts_count).to eq(0)
|
||||
expect(recipient.responses_count).to eq(0)
|
||||
end
|
||||
|
||||
it 'are updated when an attempt is responded to' do
|
||||
attempt.update(answer_index: 2)
|
||||
expect(recipient.attempts_count).to eq(1)
|
||||
expect(recipient.responses_count).to eq(1)
|
||||
end
|
||||
|
||||
it 'are updated when an attempt is responded to with an open-ended response' do
|
||||
attempt.update(open_response_id: 1)
|
||||
expect(recipient.attempts_count).to eq(1)
|
||||
expect(recipient.responses_count).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'send_message' do
|
||||
before :each do
|
||||
Timecop.freeze
|
||||
attempt.send_message
|
||||
end
|
||||
|
||||
it 'should contact the Twilio API' do
|
||||
expect(FakeSMS.messages.length).to eq(2)
|
||||
|
||||
expect(FakeSMS.messages.first.to).to eq('111111111')
|
||||
expect(FakeSMS.messages.first.body).to eq('Question 0:1')
|
||||
|
||||
expect(FakeSMS.messages.last.to).to eq('111111111')
|
||||
expect(FakeSMS.messages.last.body).to eq("Option 0:1 A: Reply 1\nOption 0:1 B: 2\nOption 0:1 C: 3\nOption 0:1 D: 4\nOption 0:1 E: 5")
|
||||
end
|
||||
|
||||
xit 'should update sent_at' do
|
||||
expect(attempt.sent_at).to eq(Time.new)
|
||||
end
|
||||
|
||||
it 'should update the recipient phone number' do
|
||||
expect(attempt.recipient.reload.phone).to eq('+1111111111')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe District, type: :model do
|
||||
let(:district1) { District.create(name: 'District one', state_id: 32) }
|
||||
let(:district2) { District.new(name: 'District two', state_id: 32) }
|
||||
|
||||
context 'when saving or creating' do
|
||||
it 'should return a slug' do
|
||||
expect(district1.slug).to eq 'district-one'
|
||||
|
||||
district2.save
|
||||
expect(district2.slug).to eq 'district-two'
|
||||
|
||||
first_district = District.find_by_slug('district-one')
|
||||
expect(first_district.slug).to eq 'district-one'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,67 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe Question, type: :model do
|
||||
let!(:school1) { School.create!(name: 'School 1') }
|
||||
let!(:school2) { School.create!(name: 'School 2') }
|
||||
|
||||
let!(:school1recipients) { create_recipients(school1, 5) }
|
||||
let!(:school2recipients) { create_recipients(school2, 4) }
|
||||
|
||||
let!(:category1) { Category.create!(name: 'Resources') }
|
||||
let!(:category2) { Category.create!(name: 'Category 2') }
|
||||
|
||||
let!(:category1questions) { create_questions(3, category1) }
|
||||
let!(:category2questions) { create_questions(3, category2) }
|
||||
let(:question) { category1questions.first }
|
||||
|
||||
let!(:attempt1) do
|
||||
Legacy::Attempt.create!(question: category1questions[0], recipient: school1recipients[0], answer_index: 3)
|
||||
end
|
||||
let!(:attempt2) do
|
||||
Legacy::Attempt.create!(question: category1questions[0], recipient: school1recipients[1], answer_index: 2)
|
||||
end
|
||||
let!(:attempt3) { Legacy::Attempt.create!(question: category1questions[0], recipient: school1recipients[2]) }
|
||||
let!(:attempt4) do
|
||||
Legacy::Attempt.create!(question: category1questions[0], recipient: school1recipients[3], answer_index: 3)
|
||||
end
|
||||
let!(:attempt5) do
|
||||
Legacy::Attempt.create!(question: category1questions[0], recipient: school2recipients[0], answer_index: 4)
|
||||
end
|
||||
let!(:attempt6) do
|
||||
Legacy::Attempt.create!(question: category1questions[1], recipient: school1recipients[0], answer_index: 5)
|
||||
end
|
||||
let!(:attempt7) do
|
||||
Legacy::Attempt.create!(question: category1questions[2], recipient: school1recipients[0], answer_index: 5)
|
||||
end
|
||||
let!(:attempt8) do
|
||||
Legacy::Attempt.create!(question: category2questions[0], recipient: school1recipients[0], answer_index: 3)
|
||||
end
|
||||
let!(:attempt9) do
|
||||
Legacy::Attempt.create!(question: category2questions[1], recipient: school1recipients[1], answer_index: 1)
|
||||
end
|
||||
|
||||
describe 'aggregated_responses_for_school' do
|
||||
let(:aggregated_responses) { question.aggregated_responses_for_school(school1) }
|
||||
|
||||
it 'aggregates all attempts with responses for the question for a given school' do
|
||||
expect(aggregated_responses.count).to eq(3)
|
||||
expect(aggregated_responses.responses.to_a).to eq([attempt1, attempt2, attempt4])
|
||||
expect(aggregated_responses.answer_index_total).to eq(8)
|
||||
end
|
||||
|
||||
it 'should calculate answer_index_average' do
|
||||
expect(aggregated_responses.answer_index_average).to eq(8.0 / 3)
|
||||
end
|
||||
|
||||
it 'should calculate the most popular answer' do
|
||||
expect(aggregated_responses.most_popular_answer).to eq(question.option3)
|
||||
end
|
||||
|
||||
it 'should provide access to the question and category' do
|
||||
expect(aggregated_responses.question).to eq(question)
|
||||
expect(aggregated_responses.category).to eq(question.category)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,55 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
describe RecipientList do
|
||||
describe 'Save' do
|
||||
it 'should convert the recipient_id_array into the recipient_ids attribute' do
|
||||
recipient_list = RecipientList.create(name: 'Name', recipient_id_array: ['', '1', '2', '3'])
|
||||
expect(recipient_list).to be_a(RecipientList)
|
||||
expect(recipient_list).to be_persisted
|
||||
expect(recipient_list.recipient_ids).to eq('1,2,3')
|
||||
|
||||
recipient_list.update(recipient_id_array: ['3', '', '4', '5', '6'])
|
||||
expect(recipient_list.reload.recipient_ids).to eq('3,4,5,6')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when edited' do
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipients) { create_recipients(school, 3) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:questions) { create_questions(3) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:schedule) do
|
||||
Schedule.create!(
|
||||
name: 'Parent Schedule',
|
||||
recipient_list_id: recipient_list.id,
|
||||
question_list:,
|
||||
random: false,
|
||||
frequency_hours: 24 * 7
|
||||
)
|
||||
end
|
||||
|
||||
it 'should delete recipient_schedules if a recipient is removed' do
|
||||
modified_recipient_ids = recipients.map(&:id)[0, 2].join(',')
|
||||
expect do
|
||||
recipient_list.update(recipient_ids: modified_recipient_ids)
|
||||
end.to change { schedule.recipient_schedules.count }.from(3).to(2)
|
||||
end
|
||||
|
||||
it 'should create recipient_schedules if a recipient is added' do
|
||||
new_recipients = create_recipients(school, 2)
|
||||
expect do
|
||||
recipient_list.update(recipient_ids: (recipients + new_recipients).map(&:id).join(','))
|
||||
end.to change { schedule.recipient_schedules.count }.from(3).to(5)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,134 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe RecipientSchedule, type: :model do
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipient) { create_recipients(school, 1).first }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipient.id.to_s)
|
||||
end
|
||||
|
||||
let(:category) { Category.create(name: 'Category') }
|
||||
let!(:questions) { create_questions(3, category) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:schedule) do
|
||||
Schedule.create!(
|
||||
name: 'Parent Schedule',
|
||||
recipient_list_id: recipient_list.id,
|
||||
question_list:,
|
||||
random: false,
|
||||
frequency_hours: 24
|
||||
)
|
||||
end
|
||||
let!(:recipient_schedule) { schedule.recipient_schedules.for_recipient(recipient).first }
|
||||
|
||||
let!(:not_ready_recipient_schedule) do
|
||||
RecipientSchedule.create!(
|
||||
recipient:,
|
||||
schedule:,
|
||||
upcoming_question_ids: '1,3',
|
||||
attempted_question_ids: '2',
|
||||
last_attempt_at: Date.today + (60 * 60 * schedule.frequency_hours),
|
||||
next_attempt_at: 1.day.from_now + (60 * 60 * schedule.frequency_hours)
|
||||
)
|
||||
end
|
||||
|
||||
xdescribe 'ready' do
|
||||
before :each do
|
||||
now = DateTime.now
|
||||
date = ActiveSupport::TimeZone['UTC'].parse(now.strftime('%Y-%m-%dT16:00:00%z'))
|
||||
Timecop.freeze(date)
|
||||
end
|
||||
|
||||
subject { schedule.recipient_schedules.ready }
|
||||
|
||||
it('should only provide recipient_schedules who are ready to send a message') do
|
||||
expect(subject.length).to eq(1)
|
||||
expect(subject.first).to eq(recipient_schedule)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'next_question' do
|
||||
it 'should provide the next question from the upcoming_question_ids list' do
|
||||
expect(recipient_schedule.next_question).to eq(questions.first)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'attempt_question' do
|
||||
before :each do
|
||||
Timecop.freeze
|
||||
end
|
||||
|
||||
describe 'with an opted out recipient' do
|
||||
before :each do
|
||||
recipient_schedule.recipient.update(opted_out: true)
|
||||
end
|
||||
|
||||
let!(:attempt) { recipient_schedule.attempt_question }
|
||||
|
||||
it 'should not do anything' do
|
||||
expect(attempt).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'right before a weekend' do
|
||||
before :each do
|
||||
friday_time = ActiveSupport::TimeZone['UTC'].parse('2017-04-21T20:00:00')
|
||||
Timecop.freeze
|
||||
recipient_schedule.update(next_attempt_at: friday_time)
|
||||
end
|
||||
|
||||
let!(:attempt) { recipient_schedule.attempt_question }
|
||||
|
||||
it 'should schedule the next attempt for after the weekend' do
|
||||
next_weekday_time = ActiveSupport::TimeZone['UTC'].parse('2017-04-24T20:00:00')
|
||||
expect(recipient_schedule.reload.next_attempt_at).to eq(next_weekday_time)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with an opted in recipient' do
|
||||
before :each do
|
||||
date = ActiveSupport::TimeZone['UTC'].parse('2017-04-20T20:00:00')
|
||||
Timecop.freeze(date)
|
||||
end
|
||||
|
||||
let!(:attempt) { recipient_schedule.attempt_question }
|
||||
|
||||
it 'should make an attempt to ask the next question' do
|
||||
expect(attempt).to be_persisted
|
||||
expect(attempt.recipient).to eq(recipient)
|
||||
expect(attempt.schedule).to eq(schedule)
|
||||
expect(attempt.recipient_schedule).to eq(recipient_schedule)
|
||||
expect(attempt.question).to eq(questions.first)
|
||||
expect(attempt.sent_at.to_i).to eq(Time.new.to_i)
|
||||
expect(attempt.answer_index).to be_nil
|
||||
end
|
||||
|
||||
it 'should update the upcoming_questions_ids' do
|
||||
expect(recipient_schedule.upcoming_question_ids).to eq(questions[1..2].map(&:id).join(','))
|
||||
end
|
||||
|
||||
it 'should update the attempted_question_ids' do
|
||||
expect(recipient_schedule.attempted_question_ids).to eq(questions.first.id.to_s)
|
||||
end
|
||||
|
||||
it 'should update last_attempt_at' do
|
||||
expect(recipient_schedule.last_attempt_at.to_i).to eq(Time.new.to_i)
|
||||
end
|
||||
|
||||
it 'should update next_attempt_at' do
|
||||
now = DateTime.now
|
||||
date = ActiveSupport::TimeZone['Eastern Time (US & Canada)'].parse(now.strftime('%Y-%m-%dT16:00:00%z'))
|
||||
date += 1.day
|
||||
date += 1.day if date.on_weekend?
|
||||
|
||||
expect(recipient_schedule.reload.next_attempt_at).to eq(date.to_time)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,51 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
describe Recipient do
|
||||
describe 'Import' do
|
||||
let(:school) { School.create!(name: 'School') }
|
||||
let(:data) { "name,phone\rJared,111-222-333\rLauren,222-333-4444\rAbby,333-444-5555\r" }
|
||||
let(:file) { instance_double('File', path: 'path') }
|
||||
|
||||
xit 'should parse file contents and return a result' do
|
||||
expect(File).to receive(:open).with('path', universal_newline: false, headers: true) { StringIO.new(data) }
|
||||
Recipient.import(school, file)
|
||||
expect(Recipient.count).to eq(3)
|
||||
expect(Recipient.all.map(&:name)).to eq(%w[Jared Lauren Abby])
|
||||
expect(Recipient.all.map(&:school).uniq).to eq([school])
|
||||
end
|
||||
end
|
||||
|
||||
describe 'When Deleted' do
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipients) { create_recipients(school, 3) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:questions) { create_questions(3) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Parent Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:schedule) do
|
||||
Schedule.create!(
|
||||
name: 'Parent Schedule',
|
||||
recipient_list_id: recipient_list.id,
|
||||
question_list:,
|
||||
random: false,
|
||||
frequency_hours: 24 * 7
|
||||
)
|
||||
end
|
||||
|
||||
it 'should delete all recipient_schedules and update all recipient_lists' do
|
||||
expect do
|
||||
recipients[1].destroy
|
||||
end.to change { schedule.recipient_schedules.count }.from(3).to(2)
|
||||
|
||||
expect(recipient_list.recipient_ids).to eq("#{recipients[0].id},#{recipients[2].id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,62 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
describe Schedule do
|
||||
let!(:school) { School.create!(name: 'School') }
|
||||
|
||||
let!(:recipients) { create_recipients(school, 3) }
|
||||
let!(:recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Parents', recipient_ids: recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:kid_recipients) { create_recipients(school, 3) }
|
||||
let!(:kids_recipient_list) do
|
||||
school.recipient_lists.create!(name: 'Kids', recipient_ids: kid_recipients.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let!(:questions) { create_questions(3) }
|
||||
let!(:question_list) do
|
||||
QuestionList.create!(name: 'Questions', question_ids: questions.map(&:id).join(','))
|
||||
end
|
||||
|
||||
let(:default_schedule_params) do
|
||||
{
|
||||
school:,
|
||||
recipient_list:,
|
||||
question_list:,
|
||||
name: 'Parents Schedule',
|
||||
description: 'Schedule for parent questions',
|
||||
start_date: 1.month.ago,
|
||||
end_date: 11.months.from_now,
|
||||
active: true
|
||||
}
|
||||
end
|
||||
|
||||
let!(:active_schedule) do
|
||||
Schedule.create!(default_schedule_params)
|
||||
end
|
||||
|
||||
let!(:active_schedule_kids) do
|
||||
Schedule.create!(default_schedule_params.merge!(name: 'Kids Schedule', recipient_list: kids_recipient_list))
|
||||
end
|
||||
|
||||
let!(:old_schedule) do
|
||||
Schedule.create!(default_schedule_params.merge!(start_date: 13.month.ago, end_date: 1.months.ago))
|
||||
end
|
||||
|
||||
let!(:paused_schedule) do
|
||||
Schedule.create!(default_schedule_params.merge!(active: false))
|
||||
end
|
||||
|
||||
describe 'active' do
|
||||
it 'finds active schedules' do
|
||||
active = Schedule.active
|
||||
expect(active.length).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it 'creates a recipient_schedule for every recipient when created' do
|
||||
expect(active_schedule.recipient_schedules.length).to eq(3)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,94 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe SchoolCategory, type: :model do
|
||||
let!(:school1) { School.create!(name: 'School 1') }
|
||||
let!(:school2) { School.create!(name: 'School 2') }
|
||||
|
||||
let!(:school1recipients) { create_recipients(school1, 4) }
|
||||
let!(:school2recipients) { create_recipients(school2, 4) }
|
||||
|
||||
let!(:category1) { Category.create!(name: 'Category 1') }
|
||||
let!(:category2) { Category.create!(name: 'Category 2') }
|
||||
|
||||
let!(:category1questions) { create_questions(3, category1) }
|
||||
let!(:category2questions) { create_questions(3, category2) }
|
||||
|
||||
let!(:attempt1) do
|
||||
Attempt.create!(question: category1questions[0], recipient: school1recipients[0], answer_index: 2)
|
||||
end
|
||||
let!(:attempt2) { Attempt.create!(question: category1questions[0], recipient: school1recipients[1]) }
|
||||
let!(:attempt3) do
|
||||
Attempt.create!(question: category1questions[0], recipient: school1recipients[2], answer_index: 3)
|
||||
end
|
||||
let!(:attempt4) do
|
||||
Attempt.create!(question: category1questions[0], recipient: school2recipients[0], answer_index: 4)
|
||||
end
|
||||
let!(:attempt5) do
|
||||
Attempt.create!(question: category1questions[1], recipient: school1recipients[0], answer_index: 5)
|
||||
end
|
||||
let!(:attempt6) do
|
||||
Attempt.create!(question: category1questions[2], recipient: school1recipients[0], answer_index: 5)
|
||||
end
|
||||
let!(:attempt7) do
|
||||
Attempt.create!(question: category2questions[0], recipient: school1recipients[0], answer_index: 3)
|
||||
end
|
||||
let!(:attempt8) do
|
||||
Attempt.create!(question: category2questions[1], recipient: school1recipients[1], answer_index: 1)
|
||||
end
|
||||
|
||||
let!(:school_category1) { SchoolCategory.for(school1, category1).first }
|
||||
|
||||
describe 'aggregated_responses' do
|
||||
xit 'should provide the count and sum of all attempts' do
|
||||
expect(school_category1.aggregated_responses).to eq(
|
||||
attempt_count: 5,
|
||||
response_count: 4,
|
||||
answer_index_total: 15
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'answer_index_average' do
|
||||
xit 'should provide the average answer_index for all responses' do
|
||||
expect(school_category1.answer_index_average).to eq(15.0 / 4.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'sync_aggregated_responses' do
|
||||
let!(:category3) { Category.create!(name: 'Category 3', parent_category: category1) }
|
||||
|
||||
let!(:category3questions) { create_questions(3, category3) }
|
||||
|
||||
let!(:attempt7) do
|
||||
Attempt.create!(question: category3questions[0], recipient: school1recipients[0], answer_index: 4)
|
||||
end
|
||||
let!(:attempt8) do
|
||||
Attempt.create!(question: category3questions[0], recipient: school1recipients[1], answer_index: 1)
|
||||
end
|
||||
let!(:attempt9) { Attempt.create!(question: category3questions[0], recipient: school1recipients[2]) }
|
||||
let!(:attempt10) do
|
||||
Attempt.create!(question: category3questions[1], recipient: school1recipients[1], answer_index: 5)
|
||||
end
|
||||
let!(:attempt11) do
|
||||
Attempt.create!(question: category3questions[1], recipient: school2recipients[0], answer_index: 5)
|
||||
end
|
||||
|
||||
let!(:school_category3) { SchoolCategory.for(school1, category3).first }
|
||||
|
||||
xit 'should update attributes and parent_category school_category attributes' do
|
||||
school_category3.sync_aggregated_responses
|
||||
|
||||
school_category3.reload
|
||||
expect(school_category3.attempt_count).to eq(4)
|
||||
expect(school_category3.response_count).to eq(3)
|
||||
expect(school_category3.answer_index_total).to eq(10)
|
||||
|
||||
school_category1.reload
|
||||
expect(school_category1.attempt_count).to eq(9)
|
||||
expect(school_category1.response_count).to eq(7)
|
||||
expect(school_category1.answer_index_total).to eq(25)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,7 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe UserSchool, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
end
|
||||
@ -1,39 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe CategoriesController, type: :routing do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/categories').to route_to('legacy/categories#index')
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: '/categories/new').to route_to('legacy/categories#new')
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: '/categories/1').to route_to('legacy/categories#show', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: '/categories/1/edit').to route_to('legacy/categories#edit', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: '/categories').to route_to('legacy/categories#create')
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: '/categories/1').to route_to('legacy/categories#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: '/categories/1').to route_to('legacy/categories#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: '/categories/1').to route_to('legacy/categories#destroy', id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,39 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe DistrictsController, type: :routing do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/districts').to route_to('legacy/districts#index')
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: '/districts/new').to route_to('legacy/districts#new')
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: '/districts/1').to route_to('legacy/districts#show', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: '/districts/1/edit').to route_to('legacy/districts#edit', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: '/districts').to route_to('legacy/districts#create')
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: '/districts/1').to route_to('legacy/districts#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: '/districts/1').to route_to('legacy/districts#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: '/districts/1').to route_to('legacy/districts#destroy', id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,39 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe Legacy::QuestionListsController, type: :routing do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/question_lists').to route_to('legacy/question_lists#index')
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: '/question_lists/new').to route_to('legacy/question_lists#new')
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: '/question_lists/1').to route_to('legacy/question_lists#show', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: '/question_lists/1/edit').to route_to('legacy/question_lists#edit', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: '/question_lists').to route_to('legacy/question_lists#create')
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: '/question_lists/1').to route_to('legacy/question_lists#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: '/question_lists/1').to route_to('legacy/question_lists#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: '/question_lists/1').to route_to('legacy/question_lists#destroy', id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,39 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe QuestionsController, type: :routing do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/questions').to route_to('legacy/questions#index')
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: '/questions/new').to route_to('legacy/questions#new')
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: '/questions/1').to route_to('legacy/questions#show', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: '/questions/1/edit').to route_to('legacy/questions#edit', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: '/questions').to route_to('legacy/questions#create')
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: '/questions/1').to route_to('legacy/questions#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: '/questions/1').to route_to('legacy/questions#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: '/questions/1').to route_to('legacy/questions#destroy', id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,54 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe RecipientListsController, type: :routing do
|
||||
describe 'routing' do
|
||||
before(:each) do
|
||||
@school = School.create!(
|
||||
name: 'MyString',
|
||||
district_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
it 'routes to #index' do
|
||||
expect(get: "schools/#{@school.id}/recipient_lists").to route_to('legacy/recipient_lists#index',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: "schools/#{@school.id}/recipient_lists/new").to route_to('legacy/recipient_lists#new',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: "schools/#{@school.id}/recipient_lists/1").to route_to('legacy/recipient_lists#show',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: "schools/#{@school.id}/recipient_lists/1/edit").to route_to('legacy/recipient_lists#edit',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: "schools/#{@school.id}/recipient_lists").to route_to('legacy/recipient_lists#create',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: "schools/#{@school.id}/recipient_lists/1").to route_to('legacy/recipient_lists#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: "schools/#{@school.id}/recipient_lists/1").to route_to('legacy/recipient_lists#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: "schools/#{@school.id}/recipient_lists/1").to route_to('legacy/recipient_lists#destroy',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,54 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe RecipientsController, type: :routing do
|
||||
describe 'routing' do
|
||||
before(:each) do
|
||||
@school = School.create!(
|
||||
name: 'MyString',
|
||||
district_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
it 'routes to #index' do
|
||||
expect(get: "schools/#{@school.id}/recipients").to route_to('legacy/recipients#index',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: "schools/#{@school.id}/recipients/new").to route_to('legacy/recipients#new',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: "schools/#{@school.id}/recipients/1").to route_to('legacy/recipients#show',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: "schools/#{@school.id}/recipients/1/edit").to route_to('legacy/recipients#edit',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: "schools/#{@school.id}/recipients").to route_to('legacy/recipients#create',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: "schools/#{@school.id}/recipients/1").to route_to('legacy/recipients#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: "schools/#{@school.id}/recipients/1").to route_to('legacy/recipients#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: "schools/#{@school.id}/recipients/1").to route_to('legacy/recipients#destroy',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,54 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe SchedulesController, type: :routing do
|
||||
describe 'routing' do
|
||||
before(:each) do
|
||||
@school = School.create!(
|
||||
name: 'MyString',
|
||||
district_id: 1
|
||||
)
|
||||
end
|
||||
|
||||
it 'routes to #index' do
|
||||
expect(get: "schools/#{@school.id}/schedules").to route_to('legacy/schedules#index',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: "schools/#{@school.id}/schedules/new").to route_to('legacy/schedules#new',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: "schools/#{@school.id}/schedules/1").to route_to('legacy/schedules#show',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: "schools/#{@school.id}/schedules/1/edit").to route_to('legacy/schedules#edit',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: "schools/#{@school.id}/schedules").to route_to('legacy/schedules#create',
|
||||
school_id: @school.id.to_s)
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: "schools/#{@school.id}/schedules/1").to route_to('legacy/schedules#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: "schools/#{@school.id}/schedules/1").to route_to('legacy/schedules#update',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: "schools/#{@school.id}/schedules/1").to route_to('legacy/schedules#destroy',
|
||||
school_id: @school.id.to_s, id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,39 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe SchoolsController, type: :routing do
|
||||
describe 'routing' do
|
||||
it 'routes to #index' do
|
||||
expect(get: '/schools').to route_to('legacy/schools#index')
|
||||
end
|
||||
|
||||
it 'routes to #new' do
|
||||
expect(get: '/schools/new').to route_to('legacy/schools#new')
|
||||
end
|
||||
|
||||
it 'routes to #show' do
|
||||
expect(get: '/schools/1').to route_to('legacy/schools#show', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #edit' do
|
||||
expect(get: '/schools/1/edit').to route_to('legacy/schools#edit', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #create' do
|
||||
expect(post: '/schools').to route_to('legacy/schools#create')
|
||||
end
|
||||
|
||||
it 'routes to #update via PUT' do
|
||||
expect(put: '/schools/1').to route_to('legacy/schools#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #update via PATCH' do
|
||||
expect(patch: '/schools/1').to route_to('legacy/schools#update', id: '1')
|
||||
end
|
||||
|
||||
it 'routes to #destroy' do
|
||||
expect(delete: '/schools/1').to route_to('legacy/schools#destroy', id: '1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,31 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/categories/edit', type: :view do
|
||||
before(:each) do
|
||||
@category = assign(:category, Category.create!(
|
||||
name: 'MyString',
|
||||
blurb: 'MyString',
|
||||
description: 'MyText',
|
||||
external_id: 'MyString',
|
||||
parent_category_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit category form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_category_path(@category), 'post' do
|
||||
assert_select 'input#category_name[name=?]', 'category[name]'
|
||||
|
||||
assert_select 'input#category_blurb[name=?]', 'category[blurb]'
|
||||
|
||||
assert_select 'textarea#category_description[name=?]', 'category[description]'
|
||||
|
||||
assert_select 'input#category_external_id[name=?]', 'category[external_id]'
|
||||
|
||||
assert_select 'input#category_parent_category_id[name=?]', 'category[parent_category_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,33 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/categories/index', type: :view do
|
||||
before(:each) do
|
||||
assign(:categories, [
|
||||
Category.create!(
|
||||
name: 'Name',
|
||||
blurb: 'Blurb',
|
||||
description: 'MyText',
|
||||
external_id: 'External',
|
||||
parent_category_id: 2
|
||||
),
|
||||
Category.create!(
|
||||
name: 'Name',
|
||||
blurb: 'Blurb',
|
||||
description: 'MyText',
|
||||
external_id: 'External',
|
||||
parent_category_id: 2
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it 'renders a list of categories' do
|
||||
render(template: 'legacy/categories/index')
|
||||
assert_select 'tr>td', text: 'Name'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Blurb'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'MyText'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'External'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 2.to_s, count: 2
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,31 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/categories/new', type: :view do
|
||||
before(:each) do
|
||||
assign(:category, Category.new(
|
||||
name: 'MyString',
|
||||
blurb: 'MyString',
|
||||
description: 'MyText',
|
||||
external_id: 'MyString',
|
||||
parent_category_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new category form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_categories_path, 'post' do
|
||||
assert_select 'input#category_name[name=?]', 'category[name]'
|
||||
|
||||
assert_select 'input#category_blurb[name=?]', 'category[blurb]'
|
||||
|
||||
assert_select 'textarea#category_description[name=?]', 'category[description]'
|
||||
|
||||
assert_select 'input#category_external_id[name=?]', 'category[external_id]'
|
||||
|
||||
assert_select 'input#category_parent_category_id[name=?]', 'category[parent_category_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'categories/show', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create(name: 'School'))
|
||||
@category = assign(:category, Category.create!(
|
||||
name: 'Category',
|
||||
description: 'MyText',
|
||||
parent_category: Category.create(name: 'Teachers And The Teaching Environment')
|
||||
))
|
||||
@school_category = assign(:school_category, SchoolCategory.create(school: @school, category: @category))
|
||||
end
|
||||
|
||||
xit 'renders attributes in <p>' do
|
||||
render
|
||||
expect(rendered).to match(/Category/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/Teachers And The Teaching Environment/)
|
||||
end
|
||||
end
|
||||
@ -1,22 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/districts/edit', type: :view do
|
||||
before(:each) do
|
||||
@district = assign(:district, Legacy::District.create!(
|
||||
name: 'MyString',
|
||||
state_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit district form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', district_path(@district), 'post' do
|
||||
assert_select 'input#district_name[name=?]', 'district[name]'
|
||||
|
||||
assert_select 'input#district_state_id[name=?]', 'district[state_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,22 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'districts/index', type: :view do
|
||||
before(:each) do
|
||||
assign(:districts, [
|
||||
District.create!(
|
||||
name: 'Name',
|
||||
state_id: 2
|
||||
),
|
||||
District.create!(
|
||||
name: 'Name',
|
||||
state_id: 2
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
xit 'renders a list of districts' do
|
||||
render
|
||||
assert_select 'tr>td', text: 'Name'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 2.to_s, count: 2
|
||||
end
|
||||
end
|
||||
@ -1,22 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/districts/new', type: :view do
|
||||
before(:each) do
|
||||
assign(:district, Legacy::District.new(
|
||||
name: 'MyString',
|
||||
state_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new district form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_districts_path, 'post' do
|
||||
assert_select 'input#district_name[name=?]', 'district[name]'
|
||||
|
||||
assert_select 'input#district_state_id[name=?]', 'district[state_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,25 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/districts/show', type: :view do
|
||||
before(:each) do
|
||||
@district = assign(:district, Legacy::District.create!(
|
||||
name: 'Milford',
|
||||
state_id: 2
|
||||
))
|
||||
|
||||
schools = []
|
||||
3.times { |i| schools << @district.schools.create!(name: "School #{i}") }
|
||||
@schools = assign(:schools, schools)
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render(template: 'legacy/districts/show')
|
||||
expect(rendered).to match(/Milford/)
|
||||
expect(rendered).to match(/2/)
|
||||
3.times do |i|
|
||||
expect(rendered).to match(/School #{i}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,25 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/question_lists/edit', type: :view do
|
||||
before(:each) do
|
||||
@question_list = assign(:question_list, QuestionList.create!(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
question_ids: 'MyText'
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit question_list form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_question_list_path(@question_list), 'post' do
|
||||
assert_select 'input#question_list_name[name=?]', 'question_list[name]'
|
||||
|
||||
assert_select 'textarea#question_list_description[name=?]', 'question_list[description]'
|
||||
|
||||
assert_select 'input[name=?]', 'question_list[question_id_array][]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,28 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/question_lists/index', type: :view do
|
||||
before(:each) do
|
||||
assign(:question_lists, [
|
||||
QuestionList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
question_ids: '1,2,3'
|
||||
),
|
||||
QuestionList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
question_ids: '2,3,4'
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it 'renders a list of question_lists' do
|
||||
render(template: 'legacy/question_lists/index')
|
||||
assert_select 'tr>td', text: 'Name'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'MyText'.to_s, count: 2
|
||||
assert_select 'tr>td', text: '1,2,3'.to_s, count: 1
|
||||
assert_select 'tr>td', text: '2,3,4'.to_s, count: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,25 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/question_lists/new', type: :view do
|
||||
before(:each) do
|
||||
assign(:question_list, QuestionList.new(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
question_ids: 'MyText'
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new question_list form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_question_lists_path, 'post' do
|
||||
assert_select 'input#question_list_name[name=?]', 'question_list[name]'
|
||||
|
||||
assert_select 'textarea#question_list_description[name=?]', 'question_list[description]'
|
||||
|
||||
assert_select 'input[name=?]', 'question_list[question_id_array][]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/question_lists/show', type: :view do
|
||||
before(:each) do
|
||||
@question_list = assign(:question_list, QuestionList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
question_ids: 'MyText'
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render(template: 'legacy/question_lists/show')
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,37 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/questions/edit', type: :view do
|
||||
before(:each) do
|
||||
@question = assign(:question, Question.create!(
|
||||
text: 'MyString',
|
||||
option1: 'MyString',
|
||||
option2: 'MyString',
|
||||
option3: 'MyString',
|
||||
option4: 'MyString',
|
||||
option5: 'MyString',
|
||||
category_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit question form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_question_path(@question), 'post' do
|
||||
assert_select 'input#question_text[name=?]', 'question[text]'
|
||||
|
||||
assert_select 'input#question_option1[name=?]', 'question[option1]'
|
||||
|
||||
assert_select 'input#question_option2[name=?]', 'question[option2]'
|
||||
|
||||
assert_select 'input#question_option3[name=?]', 'question[option3]'
|
||||
|
||||
assert_select 'input#question_option4[name=?]', 'question[option4]'
|
||||
|
||||
assert_select 'input#question_option5[name=?]', 'question[option5]'
|
||||
|
||||
assert_select 'input#question_category_id[name=?]', 'question[category_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,40 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/questions/index', type: :view do
|
||||
before(:each) do
|
||||
assign(:questions, [
|
||||
Question.create!(
|
||||
text: 'Text',
|
||||
option1: 'Option1',
|
||||
option2: 'Option2',
|
||||
option3: 'Option3',
|
||||
option4: 'Option4',
|
||||
option5: 'Option5',
|
||||
category: Category.create(name: 'Category 1')
|
||||
),
|
||||
Question.create!(
|
||||
text: 'Text',
|
||||
option1: 'Option1',
|
||||
option2: 'Option2',
|
||||
option3: 'Option3',
|
||||
option4: 'Option4',
|
||||
option5: 'Option5',
|
||||
category: Category.create(name: 'Category 2')
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it 'renders a list of questions' do
|
||||
render(template: 'legacy/questions/index')
|
||||
assert_select 'tr>td', text: 'Text'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Option1'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Option2'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Option3'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Option4'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Option5'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Category 1', count: 1
|
||||
assert_select 'tr>td', text: 'Category 2', count: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,37 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/questions/new', type: :view do
|
||||
before(:each) do
|
||||
assign(:question, Question.new(
|
||||
text: 'MyString',
|
||||
option1: 'MyString',
|
||||
option2: 'MyString',
|
||||
option3: 'MyString',
|
||||
option4: 'MyString',
|
||||
option5: 'MyString',
|
||||
category_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new question form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_questions_path, 'post' do
|
||||
assert_select 'input#question_text[name=?]', 'question[text]'
|
||||
|
||||
assert_select 'input#question_option1[name=?]', 'question[option1]'
|
||||
|
||||
assert_select 'input#question_option2[name=?]', 'question[option2]'
|
||||
|
||||
assert_select 'input#question_option3[name=?]', 'question[option3]'
|
||||
|
||||
assert_select 'input#question_option4[name=?]', 'question[option4]'
|
||||
|
||||
assert_select 'input#question_option5[name=?]', 'question[option5]'
|
||||
|
||||
assert_select 'input#question_category_id[name=?]', 'question[category_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,30 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/questions/show', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
@question = assign(:question, Question.create!(
|
||||
text: 'Question Text',
|
||||
option1: 'Option1',
|
||||
option2: 'Option2',
|
||||
option3: 'Option3',
|
||||
option4: 'Option4',
|
||||
option5: 'Option5',
|
||||
category: Category.create!(name: 'Category Name')
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render(template: 'legacy/questions/show')
|
||||
expect(rendered).to match(/School/)
|
||||
expect(rendered).to match(/Question Text/)
|
||||
expect(rendered).to match(/Option1/)
|
||||
expect(rendered).to match(/Option2/)
|
||||
expect(rendered).to match(/Option3/)
|
||||
expect(rendered).to match(/Option4/)
|
||||
expect(rendered).to match(/Option5/)
|
||||
expect(rendered).to match(/Category Name/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,31 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipient_lists/edit', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(
|
||||
name: 'School'
|
||||
))
|
||||
|
||||
@recipient_list = assign(:recipient_list, RecipientList.create!(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
recipient_ids: '1,2,3',
|
||||
school_id: @school.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit recipient_list form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_recipient_list_path(@school, @recipient_list),
|
||||
'post' do
|
||||
assert_select 'input#recipient_list_name[name=?]', 'recipient_list[name]'
|
||||
|
||||
assert_select 'textarea#recipient_list_description[name=?]', 'recipient_list[description]'
|
||||
|
||||
assert_select 'input[name=?]', 'recipient_list[recipient_id_array][]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,32 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipient_lists/index', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
assign(:recipient_lists, [
|
||||
RecipientList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
recipient_ids: '1,2,3',
|
||||
school_id: @school.id
|
||||
),
|
||||
RecipientList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
recipient_ids: '2,3,4',
|
||||
school_id: @school.id
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it 'renders a list of recipient_lists' do
|
||||
render
|
||||
assert_select 'tr>td', text: 'Name'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'MyText'.to_s, count: 2
|
||||
assert_select 'tr>td', text: '1,2,3'.to_s, count: 1
|
||||
assert_select 'tr>td', text: '2,3,4'.to_s, count: 1
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,29 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipient_lists/new', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
@recipient_list = assign(:recipient_list, RecipientList.new(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
recipient_ids: 'MyText',
|
||||
school_id: @school.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new recipient_list form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_recipient_lists_path(@school, @recipient_list),
|
||||
'post' do
|
||||
assert_select 'input#recipient_list_name[name=?]', 'recipient_list[name]'
|
||||
|
||||
assert_select 'textarea#recipient_list_description[name=?]', 'recipient_list[description]'
|
||||
|
||||
assert_select 'input[name=?]', 'recipient_list[recipient_id_array][]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,28 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipient_lists/show', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
recipients = ['Jared Cosulich', 'Lauren Cosulich'].collect do |name|
|
||||
@school.recipients.create!(name:)
|
||||
end
|
||||
|
||||
@recipient_list = assign(:recipient_list, RecipientList.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
recipient_id_array: recipients.map(&:id),
|
||||
school_id: @school.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/Jared Cosulich/)
|
||||
expect(rendered).to match(/Lauren Cosulich/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,43 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipients/edit', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:recipient, School.create!(
|
||||
name: 'School'
|
||||
))
|
||||
|
||||
@recipient = assign(:recipient, Recipient.create!(
|
||||
name: 'MyString',
|
||||
phone: 'MyString',
|
||||
gender: 'MyString',
|
||||
race: 'MyString',
|
||||
ethnicity: 'MyString',
|
||||
home_language_id: 1,
|
||||
income: 'MyString',
|
||||
opted_out: false,
|
||||
school_id: @school.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit recipient form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_recipient_path(@school, @recipient), 'post' do
|
||||
assert_select 'input#recipient_name[name=?]', 'recipient[name]'
|
||||
|
||||
assert_select 'input#recipient_phone[name=?]', 'recipient[phone]'
|
||||
|
||||
assert_select 'input#recipient_gender[name=?]', 'recipient[gender]'
|
||||
|
||||
assert_select 'input#recipient_race[name=?]', 'recipient[race]'
|
||||
|
||||
assert_select 'input#recipient_ethnicity[name=?]', 'recipient[ethnicity]'
|
||||
|
||||
assert_select 'input#recipient_home_language_id[name=?]', 'recipient[home_language_id]'
|
||||
|
||||
assert_select 'input#recipient_income[name=?]', 'recipient[income]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,47 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'legacy/recipients/index', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, Legacy::School.create!(
|
||||
name: 'School'
|
||||
))
|
||||
|
||||
assign(:recipients, [
|
||||
Legacy::Recipient.create!(
|
||||
name: 'Name',
|
||||
phone: 'Phone',
|
||||
gender: 'Gender',
|
||||
race: 'Race',
|
||||
ethnicity: 'Ethnicity',
|
||||
home_language_id: 2,
|
||||
income: 'Income',
|
||||
opted_out: false,
|
||||
school_id: @school.id
|
||||
),
|
||||
Legacy::Recipient.create!(
|
||||
name: 'Name',
|
||||
phone: 'Phone',
|
||||
gender: 'Gender',
|
||||
race: 'Race',
|
||||
ethnicity: 'Ethnicity',
|
||||
home_language_id: 2,
|
||||
income: 'Income',
|
||||
opted_out: false,
|
||||
school_id: @school.id
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it 'renders a list of recipients' do
|
||||
render(template: 'legacy/recipients/index')
|
||||
assert_select 'tr>td', text: 'Name'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Phone'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Gender'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Race'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Ethnicity'.to_s, count: 2
|
||||
assert_select 'tr>td', text: 2.to_s, count: 2
|
||||
assert_select 'tr>td', text: 'Income'.to_s, count: 2
|
||||
assert_select 'tr>td', text: false.to_s, count: 2
|
||||
assert_select 'tr>td', text: @school.id.to_s, count: 2
|
||||
end
|
||||
end
|
||||
@ -1,43 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/recipients/new', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, School.create!(
|
||||
name: 'School'
|
||||
))
|
||||
|
||||
@recipient = assign(:recipient, Recipient.new(
|
||||
name: 'MyString',
|
||||
phone: 'MyString',
|
||||
gender: 'MyString',
|
||||
race: 'MyString',
|
||||
ethnicity: 'MyString',
|
||||
home_language_id: 1,
|
||||
income: 'MyString',
|
||||
opted_out: false,
|
||||
school_id: @school.to_param
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new recipient form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_recipients_path(@school, @recipient), 'post' do
|
||||
assert_select 'input#recipient_name[name=?]', 'recipient[name]'
|
||||
|
||||
assert_select 'input#recipient_phone[name=?]', 'recipient[phone]'
|
||||
|
||||
assert_select 'input#recipient_gender[name=?]', 'recipient[gender]'
|
||||
|
||||
assert_select 'input#recipient_race[name=?]', 'recipient[race]'
|
||||
|
||||
assert_select 'input#recipient_ethnicity[name=?]', 'recipient[ethnicity]'
|
||||
|
||||
assert_select 'input#recipient_home_language_id[name=?]', 'recipient[home_language_id]'
|
||||
|
||||
assert_select 'input#recipient_income[name=?]', 'recipient[income]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,33 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'legacy/recipients/show', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, Legacy::School.create!(
|
||||
name: 'School'
|
||||
))
|
||||
|
||||
@recipient = assign(:recipient, Legacy::Recipient.create!(
|
||||
name: 'Name',
|
||||
phone: 'Phone',
|
||||
gender: 'Gender',
|
||||
race: 'Race',
|
||||
ethnicity: 'Ethnicity',
|
||||
home_language_id: 2,
|
||||
income: 'Income',
|
||||
opted_out: false,
|
||||
school_id: @school.to_param
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/Phone/)
|
||||
expect(rendered).to match(/Gender/)
|
||||
expect(rendered).to match(/Race/)
|
||||
expect(rendered).to match(/Ethnicity/)
|
||||
expect(rendered).to match(/2/)
|
||||
expect(rendered).to match(/Income/)
|
||||
expect(rendered).to match(/false/)
|
||||
end
|
||||
end
|
||||
@ -1,45 +0,0 @@
|
||||
require 'rails_helper'
|
||||
include SchedulesHelper
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/schedules/edit', type: :view do
|
||||
before(:each) do
|
||||
question_list = QuestionList.create!(name: 'Parents Questions', question_id_array: [1, 2, 3])
|
||||
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
recipient_list = RecipientList.create!(name: 'Parents', recipient_id_array: [1, 2, 3], school: @school)
|
||||
|
||||
@schedule = assign(:schedule, Schedule.create!(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
school_id: @school.id,
|
||||
frequency_hours: 1,
|
||||
active: false,
|
||||
random: false,
|
||||
recipient_list_id: recipient_list.id,
|
||||
question_list_id: question_list.id
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit schedule form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_schedule_path(@school, @schedule), 'post' do
|
||||
assert_select 'input#schedule_name[name=?]', 'schedule[name]'
|
||||
|
||||
assert_select 'textarea#schedule_description[name=?]', 'schedule[description]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[frequency_hours]'
|
||||
|
||||
assert_select 'input#schedule_active[name=?]', 'schedule[active]'
|
||||
|
||||
assert_select 'input#schedule_random[name=?]', 'schedule[random]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[recipient_list_id]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[question_list_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,45 +0,0 @@
|
||||
require 'rails_helper'
|
||||
include SchedulesHelper
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/schedules/new', type: :view do
|
||||
before(:each) do
|
||||
question_list = QuestionList.create!(name: 'Parents Questions', question_id_array: [1, 2, 3])
|
||||
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
recipient_list = RecipientList.create!(name: 'Parents', recipient_id_array: [1, 2, 3], school: @school)
|
||||
|
||||
assign(:schedule, Schedule.new(
|
||||
name: 'MyString',
|
||||
description: 'MyText',
|
||||
school: @school,
|
||||
frequency_hours: 1,
|
||||
active: false,
|
||||
random: false,
|
||||
recipient_list: @recipient_list,
|
||||
question_list: @question_list
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new schedule form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_legacy_schedules_path(@school), 'post' do
|
||||
assert_select 'input#schedule_name[name=?]', 'schedule[name]'
|
||||
|
||||
assert_select 'textarea#schedule_description[name=?]', 'schedule[description]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[frequency_hours]'
|
||||
|
||||
assert_select 'input#schedule_active[name=?]', 'schedule[active]'
|
||||
|
||||
assert_select 'input#schedule_random[name=?]', 'schedule[random]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[recipient_list_id]'
|
||||
|
||||
assert_select 'select[name=?]', 'schedule[question_list_id]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,37 +0,0 @@
|
||||
require 'rails_helper'
|
||||
include SchedulesHelper
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/schedules/show', type: :view do
|
||||
before(:each) do
|
||||
@question_list = QuestionList.create!(name: 'Parents Questions', question_id_array: [1, 2, 3])
|
||||
|
||||
@school = assign(:school, School.create!(name: 'School'))
|
||||
|
||||
@recipient_list = RecipientList.create!(name: 'Parents', recipient_id_array: [1, 2, 3], school: @school)
|
||||
|
||||
@schedule = assign(:schedule, Schedule.create!(
|
||||
name: 'Name',
|
||||
description: 'MyText',
|
||||
school: @school,
|
||||
frequency_hours: 2 * 24 * 7,
|
||||
active: false,
|
||||
random: false,
|
||||
recipient_list: @recipient_list,
|
||||
question_list: @question_list
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/MyText/)
|
||||
expect(rendered).to match(/#{@school.name}/)
|
||||
expect(rendered).to match(/Every Other Week/)
|
||||
expect(rendered).to match(/false/)
|
||||
expect(rendered).to match(/false/)
|
||||
expect(rendered).to match(/#{@recipient_list.name}/)
|
||||
expect(rendered).to match(/#{@question_list.name}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,18 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'legacy/schools/edit', type: :view do
|
||||
before(:each) do
|
||||
@school = assign(:school, Legacy::School.create!(
|
||||
name: 'MyString',
|
||||
district_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders the edit school form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_school_path(@school), 'post' do
|
||||
assert_select 'input#school_name[name=?]', 'school[name]'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,20 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/schools/new', type: :view do
|
||||
before(:each) do
|
||||
assign(:school, School.new(
|
||||
name: 'MyString',
|
||||
district_id: 1
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders new school form' do
|
||||
render
|
||||
|
||||
assert_select 'form[action=?][method=?]', legacy_schools_path, 'post' do
|
||||
assert_select 'input#school_name[name=?]', 'school[name]'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,19 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
module Legacy
|
||||
RSpec.describe 'legacy/schools/show', type: :view do
|
||||
before(:each) do
|
||||
@school_categories = []
|
||||
@school = assign(:school, School.create!(
|
||||
name: 'School',
|
||||
district: District.create(name: 'District')
|
||||
))
|
||||
end
|
||||
|
||||
it 'renders attributes in <p>' do
|
||||
render(template: 'legacy/schools/show')
|
||||
expect(rendered).to match(/School/)
|
||||
expect(rendered).to match(/District/)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in new issue