From 6b3bc835bbe5f52620374cff8c100d9d50403c36 Mon Sep 17 00:00:00 2001 From: Yuva Date: Thu, 21 Nov 2024 17:08:49 +0530 Subject: [PATCH] Add support for Rails 8 --- .github/workflows/ci.yml | 15 ++++++++++++ Gemfile | 3 ++- app/models/rapidfire/question.rb | 2 +- gemfiles/Gemfile.rails-8.0.x | 7 ++++++ rapidfire.gemspec | 6 ++--- .../rapidfire/attempts_controller_spec.rb | 2 +- spec/dummy/config/environments/development.rb | 2 +- spec/dummy/db/schema.rb | 2 +- spec/factories/answers_factory.rb | 8 +++---- spec/factories/attempts_factory.rb | 4 ++-- spec/factories/questions_factory.rb | 14 +++++------ spec/factories/surveys_factory.rb | 6 ++--- spec/factories/users_factory.rb | 4 ++-- .../rapidfire/answering_questions_spec.rb | 16 ++++++------- .../rapidfire/editing_answers_spec.rb | 12 +++++----- .../rapidfire/managing_questions_spec.rb | 6 ++--- .../rapidfire/managing_surveys_spec.rb | 6 ++--- spec/models/rapidfire/answer_spec.rb | 4 ++-- spec/models/rapidfire/question_spec.rb | 6 ++--- .../rapidfire/questions/checkbox_spec.rb | 6 ++--- spec/models/rapidfire/questions/date_spec.rb | 4 ++-- spec/models/rapidfire/questions/file_spec.rb | 4 ++-- .../rapidfire/questions/multi_file_spec.rb | 4 ++-- .../rapidfire/questions/numeric_spec.rb | 4 ++-- .../models/rapidfire/questions/select_spec.rb | 6 ++--- spec/models/rapidfire/survey_spec.rb | 2 +- .../question_result_serializer_spec.rb | 2 +- .../rapidfire/attempt_builder_spec.rb | 10 ++++---- spec/services/rapidfire/question_form_spec.rb | 6 ++--- .../services/rapidfire/survey_results_spec.rb | 2 +- spec/spec_helper.rb | 2 +- spec/support/rapidfire/answer_spec_helper.rb | 24 +++++++++---------- .../support/rapidfire/question_spec_helper.rb | 14 +++++------ ...hange_delimiter_from_comma_to_srsn_spec.rb | 16 ++++++------- 34 files changed, 127 insertions(+), 104 deletions(-) create mode 100644 gemfiles/Gemfile.rails-8.0.x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66136d9d..e904dc4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,11 @@ name: Tests + on: + pull_request: push: branches: - master + jobs: rspec: runs-on: ubuntu-latest @@ -19,6 +22,7 @@ jobs: - 6.0.0 - 6.1.0 - 7.0.0 + - 8.0.0 # https://www.ruby-lang.org/en/downloads/ ruby: - 2.4.10 # not maintained by ruby team @@ -81,6 +85,17 @@ jobs: ruby: 2.5.9 - rails: 7.0.0 ruby: 2.6.10 + # Rails 8 needs ruby >= 3.1.0 + - rails: 8.0.0 + ruby: 2.4.10 + - rails: 8.0.0 + ruby: 2.5.9 + - rails: 8.0.0 + ruby: 2.6.10 + - rails: 8.0.0 + ruby: 2.7.8 + - rails: 8.0.0 + ruby: 3.0.6 services: postgres: image: postgres:11-alpine diff --git a/Gemfile b/Gemfile index 125dfa4f..ba5c6c34 100644 --- a/Gemfile +++ b/Gemfile @@ -2,8 +2,9 @@ source 'https://rubygems.org' gemspec -gem 'rails', "~> #{ENV['RAILS_VERSION']}" +gem 'rails', '~> 8.0.0' gem 'pg' +gem 'ostruct' group :development, :test do gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] diff --git a/app/models/rapidfire/question.rb b/app/models/rapidfire/question.rb index 07f034f7..cddeb6af 100644 --- a/app/models/rapidfire/question.rb +++ b/app/models/rapidfire/question.rb @@ -7,7 +7,7 @@ class Question < ApplicationRecord validates :survey, :question_text, :presence => true validate :type_can_change - serialize :validation_rules + serialize :validation_rules, coder: YAML def self.inherited(child) child.instance_eval do diff --git a/gemfiles/Gemfile.rails-8.0.x b/gemfiles/Gemfile.rails-8.0.x new file mode 100644 index 00000000..dbc0ed31 --- /dev/null +++ b/gemfiles/Gemfile.rails-8.0.x @@ -0,0 +1,7 @@ +# -*- ruby -*- + +source 'https://rubygems.org' + +gemspec path: '..' +gem 'rails', '~> 8.0.0' +gem 'ostruct' diff --git a/rapidfire.gemspec b/rapidfire.gemspec index 9aa1ec08..15debd51 100644 --- a/rapidfire.gemspec +++ b/rapidfire.gemspec @@ -20,13 +20,13 @@ There is breaking delimiter change when upgrading to version 2.0.0. Please see Readme for more information. PIM - s.add_dependency 'rails', '>= 3.2.13' + s.add_dependency 'rails', '>= 7.0.0' s.add_dependency 'active_model_serializers', '~> 0.10.0' s.add_development_dependency 'sqlite3' - s.add_development_dependency 'rspec-rails', '~> 3.6.1' + s.add_development_dependency 'rspec-rails' s.add_development_dependency 'shoulda' s.add_development_dependency 'database_cleaner' - s.add_development_dependency 'factory_girl_rails' + s.add_development_dependency 'factory_bot_rails' s.add_development_dependency 'capybara' s.add_development_dependency 'launchy' s.add_development_dependency 'minitest' diff --git a/spec/controllers/rapidfire/attempts_controller_spec.rb b/spec/controllers/rapidfire/attempts_controller_spec.rb index 13554e76..1bbffc1d 100644 --- a/spec/controllers/rapidfire/attempts_controller_spec.rb +++ b/spec/controllers/rapidfire/attempts_controller_spec.rb @@ -10,7 +10,7 @@ # any default value. context 'when no parameters are passed' do it 'initializes answer builder with empty args' do - survey = FactoryGirl.create(:survey) + survey = FactoryBot.create(:survey) if Rails::VERSION::MAJOR >= 5 expect { diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb index 6abb655f..a8080286 100644 --- a/spec/dummy/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -21,5 +21,5 @@ config.whiny_nils = false # Expands the lines which load the assets - config.assets.debug = true + # config.assets.debug = true end diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 55e89aac..9e46bdb1 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_04_02_174122) do +ActiveRecord::Schema[8.0].define(version: 2023_04_02_174122) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false diff --git a/spec/factories/answers_factory.rb b/spec/factories/answers_factory.rb index 2817fe28..d5396148 100644 --- a/spec/factories/answers_factory.rb +++ b/spec/factories/answers_factory.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :answer, :class => "Rapidfire::Answer" do - attempt { FactoryGirl.create(:attempt) } - question { FactoryGirl.create(:q_long) } - answer_text "hello world" + attempt { FactoryBot.create(:attempt) } + question { FactoryBot.create(:q_long) } + answer_text { "hello world" } end end diff --git a/spec/factories/attempts_factory.rb b/spec/factories/attempts_factory.rb index c373d26b..284ca468 100644 --- a/spec/factories/attempts_factory.rb +++ b/spec/factories/attempts_factory.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :attempt, :class => "Rapidfire::Attempt" do - survey { FactoryGirl.create(:survey) } + survey { FactoryBot.create(:survey) } end end diff --git a/spec/factories/questions_factory.rb b/spec/factories/questions_factory.rb index 6f43a75c..168f5631 100644 --- a/spec/factories/questions_factory.rb +++ b/spec/factories/questions_factory.rb @@ -1,10 +1,10 @@ -FactoryGirl.define do - factory :question do - survey { FactoryGirl.create(:survey) } - question_text "Sample Question" +FactoryBot.define do + factory :question, :class => "Rapidfire::Question" do + survey { FactoryBot.create(:survey) } + question_text { "Sample Question" } factory :q_checkbox, :class => "Rapidfire::Questions::Checkbox" do - answer_options "hindi\r\ntelugu\r\nkannada\r\n" + answer_options { "hindi\r\ntelugu\r\nkannada\r\n" } end factory :q_date, :class => "Rapidfire::Questions::Date" do @@ -17,11 +17,11 @@ end factory :q_radio, :class => "Rapidfire::Questions::Radio" do - answer_options "male\r\nfemale\r\n" + answer_options { "male\r\nfemale\r\n" } end factory :q_select, :class => "Rapidfire::Questions::Select" do - answer_options "mac\r\nwindows\r\n" + answer_options { "mac\r\nwindows\r\n" } end factory :q_short, :class => "Rapidfire::Questions::Short" do diff --git a/spec/factories/surveys_factory.rb b/spec/factories/surveys_factory.rb index 7e4bc4d2..5935091e 100644 --- a/spec/factories/surveys_factory.rb +++ b/spec/factories/surveys_factory.rb @@ -1,6 +1,6 @@ -FactoryGirl.define do +FactoryBot.define do factory :survey, :class => "Rapidfire::Survey" do - name "Test Survey" - introduction "Please answer all the questions in this survey." + name { "Test Survey" } + introduction { "Please answer all the questions in this survey." } end end diff --git a/spec/factories/users_factory.rb b/spec/factories/users_factory.rb index a3738348..cee04c86 100644 --- a/spec/factories/users_factory.rb +++ b/spec/factories/users_factory.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :user do - name "Test User" + name { "Test User" } end end diff --git a/spec/features/rapidfire/answering_questions_spec.rb b/spec/features/rapidfire/answering_questions_spec.rb index ca73a119..cdadefe4 100644 --- a/spec/features/rapidfire/answering_questions_spec.rb +++ b/spec/features/rapidfire/answering_questions_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe "Surveys" do - let!(:survey) { FactoryGirl.create(:survey, name: "Question Set", introduction: "Some introduction") } + let!(:survey) { FactoryBot.create(:survey, name: "Question Set", introduction: "Some introduction") } it "displays survey introduction" do visit rapidfire.new_survey_attempt_path(survey) @@ -10,10 +10,10 @@ end describe "Answering Questions" do - let!(:question1) { FactoryGirl.create(:q_long, survey: survey, question_text: "Long Question", validation_rules: { presence: "1" }) } - let!(:question2) { FactoryGirl.create(:q_short, survey: survey, question_text: "Short Question") } - let!(:question3) { FactoryGirl.create(:q_checkbox, survey: survey, question_text: "Checkbox question") } - let!(:question4) { FactoryGirl.create(:q_checkbox, survey: survey, question_text: "Checkbox question", validation_rules: { presence: "1" }) } + let!(:question1) { FactoryBot.create(:q_long, survey: survey, question_text: "Long Question", validation_rules: { presence: "1" }) } + let!(:question2) { FactoryBot.create(:q_short, survey: survey, question_text: "Short Question") } + let!(:question3) { FactoryBot.create(:q_checkbox, survey: survey, question_text: "Checkbox question") } + let!(:question4) { FactoryBot.create(:q_checkbox, survey: survey, question_text: "Checkbox question", validation_rules: { presence: "1" }) } before do visit rapidfire.new_survey_attempt_path(survey) @@ -92,7 +92,7 @@ if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2" describe "Answering File uploads" do context "when the question is single file upload" do - let!(:question1) { FactoryGirl.create(:q_file, survey: survey, question_text: "Avatar") } + let!(:question1) { FactoryBot.create(:q_file, survey: survey, question_text: "Avatar") } it "persistes the file" do visit rapidfire.new_survey_attempt_path(survey) @@ -107,7 +107,7 @@ end context "when the question is multi file upload" do - let!(:question1) { FactoryGirl.create(:q_multifile, survey: survey, question_text: "Images") } + let!(:question1) { FactoryBot.create(:q_multifile, survey: survey, question_text: "Images") } it "persistes the file" do visit rapidfire.new_survey_attempt_path(survey) @@ -125,7 +125,7 @@ end context "when persisting a file fails" do - let!(:question1) { FactoryGirl.create(:q_file, survey: survey, question_text: "Avatar") } + let!(:question1) { FactoryBot.create(:q_file, survey: survey, question_text: "Avatar") } it "bubbles up the error" do visit rapidfire.new_survey_attempt_path(survey) diff --git a/spec/features/rapidfire/editing_answers_spec.rb b/spec/features/rapidfire/editing_answers_spec.rb index fb6f9134..e8f0aa39 100644 --- a/spec/features/rapidfire/editing_answers_spec.rb +++ b/spec/features/rapidfire/editing_answers_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe "Surveys" do - let(:survey) { FactoryGirl.create(:survey, name: "Question Set") } - let(:question1) { FactoryGirl.create(:q_long, survey: survey, question_text: "Long Question", validation_rules: { presence: "1" }) } - let(:question2) { FactoryGirl.create(:q_short, survey: survey, question_text: "Short Question") } - let(:attempt) { FactoryGirl.create(:attempt, survey: survey) } - let!(:answer1) { FactoryGirl.create(:answer, attempt: attempt, question: question1, answer_text: "Long Answer") } - let!(:answer2) { FactoryGirl.create(:answer, attempt: attempt, question: question2, answer_text: "Short Answer") } + let(:survey) { FactoryBot.create(:survey, name: "Question Set") } + let(:question1) { FactoryBot.create(:q_long, survey: survey, question_text: "Long Question", validation_rules: { presence: "1" }) } + let(:question2) { FactoryBot.create(:q_short, survey: survey, question_text: "Short Question") } + let(:attempt) { FactoryBot.create(:attempt, survey: survey) } + let!(:answer1) { FactoryBot.create(:answer, attempt: attempt, question: question1, answer_text: "Long Answer") } + let!(:answer2) { FactoryBot.create(:answer, attempt: attempt, question: question2, answer_text: "Short Answer") } before do visit rapidfire.edit_survey_attempt_path(survey, attempt) end diff --git a/spec/features/rapidfire/managing_questions_spec.rb b/spec/features/rapidfire/managing_questions_spec.rb index ef3ce703..904528e8 100644 --- a/spec/features/rapidfire/managing_questions_spec.rb +++ b/spec/features/rapidfire/managing_questions_spec.rb @@ -1,9 +1,9 @@ require 'spec_helper' describe "Questions" do - let(:survey) { FactoryGirl.create(:survey, name: "Question Set") } - let(:question1) { FactoryGirl.create(:q_long, survey: survey, question_text: "Long Question") } - let(:question2) { FactoryGirl.create(:q_short, survey: survey, question_text: "Short Question") } + let(:survey) { FactoryBot.create(:survey, name: "Question Set") } + let(:question1) { FactoryBot.create(:q_long, survey: survey, question_text: "Long Question") } + let(:question2) { FactoryBot.create(:q_short, survey: survey, question_text: "Short Question") } before do [question1, question2] end diff --git a/spec/features/rapidfire/managing_surveys_spec.rb b/spec/features/rapidfire/managing_surveys_spec.rb index 2590a990..5d45e4ec 100644 --- a/spec/features/rapidfire/managing_surveys_spec.rb +++ b/spec/features/rapidfire/managing_surveys_spec.rb @@ -4,9 +4,9 @@ include Rapidfire::QuestionSpecHelper include Rapidfire::AnswerSpecHelper - let(:survey) { FactoryGirl.create(:survey, name: "Question Set") } - let(:question1) { FactoryGirl.create(:q_long, survey: survey, question_text: "Long Question") } - let(:question2) { FactoryGirl.create(:q_short, survey: survey, question_text: "Short Question") } + let(:survey) { FactoryBot.create(:survey, name: "Question Set") } + let(:question1) { FactoryBot.create(:q_long, survey: survey, question_text: "Long Question") } + let(:question2) { FactoryBot.create(:q_short, survey: survey, question_text: "Short Question") } before do [question1, question2] end diff --git a/spec/models/rapidfire/answer_spec.rb b/spec/models/rapidfire/answer_spec.rb index 18c49529..24b23084 100644 --- a/spec/models/rapidfire/answer_spec.rb +++ b/spec/models/rapidfire/answer_spec.rb @@ -2,12 +2,12 @@ describe Rapidfire::Answer do describe "Validations" do - subject { FactoryGirl.build(:answer) } + subject { FactoryBot.build(:answer) } it { is_expected.to validate_presence_of(:question) } it { is_expected.to validate_presence_of(:attempt) } context "when validations are run" do - let(:answer) { FactoryGirl.build(:answer) } + let(:answer) { FactoryBot.build(:answer) } it "delegates validation of answer text to question" do expect(answer.question).to receive(:validate_answer).with(answer).once diff --git a/spec/models/rapidfire/question_spec.rb b/spec/models/rapidfire/question_spec.rb index 54814c52..cec294e4 100644 --- a/spec/models/rapidfire/question_spec.rb +++ b/spec/models/rapidfire/question_spec.rb @@ -11,7 +11,7 @@ end describe "#rules" do - let(:question) { FactoryGirl.create(:q_long, validation_rules: validation_rules) } + let(:question) { FactoryBot.create(:q_long, validation_rules: validation_rules) } context "when there are no validation rules" do let(:validation_rules) { {} } @@ -33,8 +33,8 @@ end describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_long, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, answer_text: answer_text) } + let(:question) { FactoryBot.create(:q_long, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, answer_text: answer_text) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/checkbox_spec.rb b/spec/models/rapidfire/questions/checkbox_spec.rb index 9927424b..18995106 100644 --- a/spec/models/rapidfire/questions/checkbox_spec.rb +++ b/spec/models/rapidfire/questions/checkbox_spec.rb @@ -6,7 +6,7 @@ end describe "#options" do - let(:question) { FactoryGirl.create(:q_select) } + let(:question) { FactoryBot.create(:q_select) } it "returns options" do expect(question.options).to match_array(["mac", "windows"]) @@ -14,8 +14,8 @@ end describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_checkbox, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, answer_text: answer_text) } + let(:question) { FactoryBot.create(:q_checkbox, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, answer_text: answer_text) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/date_spec.rb b/spec/models/rapidfire/questions/date_spec.rb index c8aee9b9..97bc1110 100644 --- a/spec/models/rapidfire/questions/date_spec.rb +++ b/spec/models/rapidfire/questions/date_spec.rb @@ -2,8 +2,8 @@ describe Rapidfire::Questions::Date do describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_date, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, answer_text: answer_text) } + let(:question) { FactoryBot.create(:q_date, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, answer_text: answer_text) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/file_spec.rb b/spec/models/rapidfire/questions/file_spec.rb index fb75bb42..64e3bf13 100644 --- a/spec/models/rapidfire/questions/file_spec.rb +++ b/spec/models/rapidfire/questions/file_spec.rb @@ -16,8 +16,8 @@ def fixture_file_upload(path, mime_type) if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2" describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_file, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, file: file) } + let(:question) { FactoryBot.create(:q_file, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, file: file) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/multi_file_spec.rb b/spec/models/rapidfire/questions/multi_file_spec.rb index a01a4e35..6c4789c1 100644 --- a/spec/models/rapidfire/questions/multi_file_spec.rb +++ b/spec/models/rapidfire/questions/multi_file_spec.rb @@ -16,8 +16,8 @@ def fixture_file_upload(path, mime_type) if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2" describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_multifile, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, files: files) } + let(:question) { FactoryBot.create(:q_multifile, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, files: files) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/numeric_spec.rb b/spec/models/rapidfire/questions/numeric_spec.rb index 424ec425..9fd945b0 100644 --- a/spec/models/rapidfire/questions/numeric_spec.rb +++ b/spec/models/rapidfire/questions/numeric_spec.rb @@ -2,8 +2,8 @@ describe Rapidfire::Questions::Numeric do describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_numeric, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, answer_text: answer_text) } + let(:question) { FactoryBot.create(:q_numeric, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, answer_text: answer_text) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/questions/select_spec.rb b/spec/models/rapidfire/questions/select_spec.rb index 49f9b33d..6d659593 100644 --- a/spec/models/rapidfire/questions/select_spec.rb +++ b/spec/models/rapidfire/questions/select_spec.rb @@ -6,7 +6,7 @@ end describe "#options" do - let(:question) { FactoryGirl.create(:q_select) } + let(:question) { FactoryBot.create(:q_select) } it "returns options" do expect(question.options).to match_array(["mac", "windows"]) @@ -14,8 +14,8 @@ end describe "validate_answer" do - let(:question) { FactoryGirl.create(:q_select, validation_rules: validation_rules) } - let(:answer) { FactoryGirl.build(:answer, question: question, answer_text: answer_text) } + let(:question) { FactoryBot.create(:q_select, validation_rules: validation_rules) } + let(:answer) { FactoryBot.build(:answer, question: question, answer_text: answer_text) } before { answer.valid? } context "when there are no validation rules" do diff --git a/spec/models/rapidfire/survey_spec.rb b/spec/models/rapidfire/survey_spec.rb index 48109aa8..4a9caffa 100644 --- a/spec/models/rapidfire/survey_spec.rb +++ b/spec/models/rapidfire/survey_spec.rb @@ -12,7 +12,7 @@ end describe "factory" do - let(:survey) { FactoryGirl.create(:survey) } + let(:survey) { FactoryBot.create(:survey) } it "has a name" do expect(survey.name).to eql("Test Survey") diff --git a/spec/serializers/rapidfire/question_result_serializer_spec.rb b/spec/serializers/rapidfire/question_result_serializer_spec.rb index b94fddbd..a9568290 100644 --- a/spec/serializers/rapidfire/question_result_serializer_spec.rb +++ b/spec/serializers/rapidfire/question_result_serializer_spec.rb @@ -4,7 +4,7 @@ include Rapidfire::QuestionSpecHelper include Rapidfire::AnswerSpecHelper - let(:survey) { FactoryGirl.create(:survey) } + let(:survey) { FactoryBot.create(:survey) } let(:results) do Rapidfire::SurveyResults.new(survey: survey).extract end diff --git a/spec/services/rapidfire/attempt_builder_spec.rb b/spec/services/rapidfire/attempt_builder_spec.rb index 1020b1c3..5748a764 100644 --- a/spec/services/rapidfire/attempt_builder_spec.rb +++ b/spec/services/rapidfire/attempt_builder_spec.rb @@ -5,9 +5,9 @@ def fixture_file_upload(path, mime_type) end describe Rapidfire::AttemptBuilder do - let(:survey) { FactoryGirl.create(:survey) } - let(:question1) { FactoryGirl.create(:q_short, survey: survey) } - let(:question2) { FactoryGirl.create(:q_long, survey: survey, + let(:survey) { FactoryBot.create(:survey) } + let(:question1) { FactoryBot.create(:q_short, survey: survey) } + let(:question2) { FactoryBot.create(:q_long, survey: survey, validation_rules: { presence: "1" }) } describe "Creation" do @@ -91,7 +91,7 @@ def fixture_file_upload(path, mime_type) if "#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}" >= "5.2" context "with a single file upload question" do - let(:question3) { FactoryGirl.create(:q_file, survey: survey) } + let(:question3) { FactoryBot.create(:q_file, survey: survey) } let(:answer_params) do { @@ -111,7 +111,7 @@ def fixture_file_upload(path, mime_type) end context "with multiple files upload question" do - let(:question3) { FactoryGirl.create(:q_multifile, survey: survey) } + let(:question3) { FactoryBot.create(:q_multifile, survey: survey) } let(:answer_params) do { diff --git a/spec/services/rapidfire/question_form_spec.rb b/spec/services/rapidfire/question_form_spec.rb index 09b854c8..62598e2a 100644 --- a/spec/services/rapidfire/question_form_spec.rb +++ b/spec/services/rapidfire/question_form_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Rapidfire::QuestionForm do - let(:survey) { FactoryGirl.create(:survey) } + let(:survey) { FactoryBot.create(:survey) } describe "Creation" do let(:proxy) { described_class.new(survey: survey) } @@ -19,7 +19,7 @@ end context "when a question is passed" do - let(:question) { FactoryGirl.create(:q_checkbox, survey: survey) } + let(:question) { FactoryBot.create(:q_checkbox, survey: survey) } let(:proxy) { described_class.new(survey: survey, question: question) } it "persists question params" do @@ -75,7 +75,7 @@ end context "updating a question" do - let(:question) { FactoryGirl.create(:q_checkbox, survey: survey) } + let(:question) { FactoryBot.create(:q_checkbox, survey: survey) } let(:proxy) do proxy_params = params.merge(survey: survey, question: question) described_class.new(proxy_params) diff --git a/spec/services/rapidfire/survey_results_spec.rb b/spec/services/rapidfire/survey_results_spec.rb index 32e47b3b..9bfafd19 100644 --- a/spec/services/rapidfire/survey_results_spec.rb +++ b/spec/services/rapidfire/survey_results_spec.rb @@ -4,7 +4,7 @@ include Rapidfire::QuestionSpecHelper include Rapidfire::AnswerSpecHelper - let(:survey) { FactoryGirl.create(:survey) } + let(:survey) { FactoryBot.create(:survey) } describe '#extract' do before do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9b195721..92ec626c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,7 +4,7 @@ require 'rspec/rails' require 'capybara/rails' -require 'factory_girl_rails' +require 'factory_bot_rails' require 'database_cleaner' require 'shoulda' diff --git a/spec/support/rapidfire/answer_spec_helper.rb b/spec/support/rapidfire/answer_spec_helper.rb index 0f50faf8..4b96f9bd 100644 --- a/spec/support/rapidfire/answer_spec_helper.rb +++ b/spec/support/rapidfire/answer_spec_helper.rb @@ -1,22 +1,22 @@ module Rapidfire module AnswerSpecHelper def create_answers - FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => 'hindi') - FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\ntelugu") - FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\nkannada") + FactoryBot.create(:answer, :question => @question_checkbox, :answer_text => 'hindi') + FactoryBot.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\ntelugu") + FactoryBot.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\nkannada") - FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'mac') - FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'mac') - FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'windows') + FactoryBot.create(:answer, :question => @question_select, :answer_text => 'mac') + FactoryBot.create(:answer, :question => @question_select, :answer_text => 'mac') + FactoryBot.create(:answer, :question => @question_select, :answer_text => 'windows') - FactoryGirl.create(:answer, :question => @question_radio, :answer_text => 'male') - FactoryGirl.create(:answer, :question => @question_radio, :answer_text => 'female') + FactoryBot.create(:answer, :question => @question_radio, :answer_text => 'male') + FactoryBot.create(:answer, :question => @question_radio, :answer_text => 'female') 3.times do - FactoryGirl.create(:answer, :question => @question_date, :answer_text => Date.today.to_s) - FactoryGirl.create(:answer, :question => @question_long, :answer_text => 'my bio goes on and on!') - FactoryGirl.create(:answer, :question => @question_numeric, :answer_text => 999) - FactoryGirl.create(:answer, :question => @question_short, :answer_text => 'this is cool') + FactoryBot.create(:answer, :question => @question_date, :answer_text => Date.today.to_s) + FactoryBot.create(:answer, :question => @question_long, :answer_text => 'my bio goes on and on!') + FactoryBot.create(:answer, :question => @question_numeric, :answer_text => 999) + FactoryBot.create(:answer, :question => @question_short, :answer_text => 'this is cool') end end end diff --git a/spec/support/rapidfire/question_spec_helper.rb b/spec/support/rapidfire/question_spec_helper.rb index b4acf472..9419635d 100644 --- a/spec/support/rapidfire/question_spec_helper.rb +++ b/spec/support/rapidfire/question_spec_helper.rb @@ -1,13 +1,13 @@ module Rapidfire module QuestionSpecHelper def create_questions(survey) - @question_checkbox = FactoryGirl.create(:q_checkbox, :survey => survey) - @question_date = FactoryGirl.create(:q_date, :survey => survey) - @question_long = FactoryGirl.create(:q_long, :survey => survey) - @question_numeric = FactoryGirl.create(:q_numeric, :survey => survey) - @question_radio = FactoryGirl.create(:q_radio, :survey => survey) - @question_select = FactoryGirl.create(:q_select, :survey => survey) - @question_short = FactoryGirl.create(:q_short, :survey => survey) + @question_checkbox = FactoryBot.create(:q_checkbox, :survey => survey) + @question_date = FactoryBot.create(:q_date, :survey => survey) + @question_long = FactoryBot.create(:q_long, :survey => survey) + @question_numeric = FactoryBot.create(:q_numeric, :survey => survey) + @question_radio = FactoryBot.create(:q_radio, :survey => survey) + @question_select = FactoryBot.create(:q_select, :survey => survey) + @question_short = FactoryBot.create(:q_short, :survey => survey) end end end diff --git a/spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb b/spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb index d7499e6c..749a93d8 100644 --- a/spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb +++ b/spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb @@ -9,18 +9,18 @@ end it 'converts select,radio and checkbox answer options delimiter from , to \r\n' do - survey = FactoryGirl.create(:survey) - q_checkbox = FactoryGirl.create(:q_checkbox, survey: survey, + survey = FactoryBot.create(:survey) + q_checkbox = FactoryBot.create(:q_checkbox, survey: survey, answer_options: 'one,two,three') - q_radio = FactoryGirl.create(:q_radio, survey: survey, + q_radio = FactoryBot.create(:q_radio, survey: survey, answer_options: 'hello,world') - q_select = FactoryGirl.create(:q_select, survey: survey, + q_select = FactoryBot.create(:q_select, survey: survey, answer_options: 'new,old,historic,') - q_date = FactoryGirl.create(:q_date, survey: survey) - q_long = FactoryGirl.create(:q_long, survey: survey) - q_numeric = FactoryGirl.create(:q_numeric, survey: survey) - q_short = FactoryGirl.create(:q_short, survey: survey) + q_date = FactoryBot.create(:q_date, survey: survey) + q_long = FactoryBot.create(:q_long, survey: survey) + q_numeric = FactoryBot.create(:q_numeric, survey: survey) + q_short = FactoryBot.create(:q_short, survey: survey) Rake::Task['rapidfire:change_delimiter_from_comma_to_srsn'].invoke