rapidfire 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -13
- data/app/controllers/rapidfire/attempts_controller.rb +29 -0
- data/app/controllers/rapidfire/questions_controller.rb +35 -34
- data/app/controllers/rapidfire/surveys_controller.rb +60 -0
- data/app/models/rapidfire/answer.rb +3 -3
- data/app/models/rapidfire/attempt.rb +11 -0
- data/app/models/rapidfire/question.rb +3 -3
- data/app/models/rapidfire/{question_group.rb → survey.rb} +1 -1
- data/app/services/rapidfire/{answer_group_builder.rb → attempt_builder.rb} +12 -12
- data/app/services/rapidfire/base_service.rb +1 -1
- data/app/services/rapidfire/question_form.rb +4 -4
- data/app/services/rapidfire/{question_group_results.rb → survey_results.rb} +3 -3
- data/app/views/rapidfire/{answer_groups → attempts}/new.html.erb +2 -2
- data/app/views/rapidfire/questions/_question.html.erb +2 -2
- data/app/views/rapidfire/questions/edit.html.erb +1 -1
- data/app/views/rapidfire/questions/index.html.erb +1 -1
- data/app/views/rapidfire/questions/new.html.erb +1 -1
- data/app/views/rapidfire/surveys/_form.html.erb +15 -0
- data/app/views/rapidfire/surveys/_survey.html.erb +18 -0
- data/app/views/rapidfire/{question_groups → surveys}/index.html.erb +4 -4
- data/app/views/rapidfire/surveys/new.html.erb +1 -0
- data/app/views/rapidfire/{question_groups → surveys}/results.html.erb +1 -1
- data/config/routes.rb +3 -3
- data/db/migrate/20130502170733_create_rapidfire_question_groups.rb +1 -1
- data/db/migrate/20130502195310_create_rapidfire_questions.rb +2 -2
- data/db/migrate/20130502195415_create_rapidfire_answer_groups.rb +4 -4
- data/db/migrate/20130502195504_create_rapidfire_answers.rb +2 -2
- data/lib/generators/rapidfire/templates/migrations/rename_answer_groups_and_question_groups.rb +9 -0
- data/lib/generators/rapidfire/upgrade_migration_generator.rb +18 -0
- data/lib/generators/rapidfire/views_generator.rb +4 -4
- data/lib/rapidfire/version.rb +1 -1
- data/lib/tasks/rapidfire.rake +10 -0
- data/spec/controllers/rapidfire/attempts_controller_spec.rb +20 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +11 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +72 -0
- data/spec/dummy/config/environments/test.rb +41 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +8 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +53 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +394 -0
- data/spec/dummy/log/test.log +2380 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/answers_factory.rb +7 -0
- data/spec/factories/attempts_factory.rb +5 -0
- data/spec/factories/questions_factory.rb +30 -0
- data/spec/factories/surveys_factory.rb +5 -0
- data/spec/features/rapidfire/answering_questions_spec.rb +55 -0
- data/spec/features/rapidfire/managing_questions_spec.rb +95 -0
- data/spec/features/rapidfire/managing_surveys_spec.rb +141 -0
- data/spec/models/rapidfire/answer_spec.rb +23 -0
- data/spec/models/rapidfire/attempt_spec.rb +9 -0
- data/spec/models/rapidfire/question_spec.rb +123 -0
- data/spec/models/rapidfire/questions/checkbox_spec.rb +90 -0
- data/spec/models/rapidfire/questions/date_spec.rb +78 -0
- data/spec/models/rapidfire/questions/numeric_spec.rb +114 -0
- data/spec/models/rapidfire/questions/select_spec.rb +90 -0
- data/spec/models/rapidfire/survey_spec.rb +11 -0
- data/spec/serializers/rapidfire/question_result_serializer_spec.rb +44 -0
- data/spec/services/rapidfire/attempt_builder_spec.rb +88 -0
- data/spec/services/rapidfire/question_form_spec.rb +93 -0
- data/spec/services/rapidfire/survey_results_spec.rb +63 -0
- data/spec/spec_helper.rb +68 -0
- data/spec/support/rapidfire/answer_spec_helper.rb +23 -0
- data/spec/support/rapidfire/question_spec_helper.rb +13 -0
- data/spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb +31 -0
- metadata +133 -30
- data/app/controllers/rapidfire/answer_groups_controller.rb +0 -29
- data/app/controllers/rapidfire/question_groups_controller.rb +0 -59
- data/app/models/rapidfire/answer_group.rb +0 -11
- data/app/views/rapidfire/question_groups/_form.html.erb +0 -15
- data/app/views/rapidfire/question_groups/_question_group.html.erb +0 -18
- data/app/views/rapidfire/question_groups/new.html.erb +0 -1
@@ -0,0 +1,44 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rapidfire::QuestionResultSerializer do
|
4
|
+
include Rapidfire::QuestionSpecHelper
|
5
|
+
include Rapidfire::AnswerSpecHelper
|
6
|
+
|
7
|
+
let(:survey) { FactoryGirl.create(:survey) }
|
8
|
+
let(:results) do
|
9
|
+
Rapidfire::SurveyResults.new(survey: survey).extract
|
10
|
+
end
|
11
|
+
|
12
|
+
before do
|
13
|
+
create_questions(survey)
|
14
|
+
create_answers
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#to_json" do
|
18
|
+
let(:aggregatable_result) do
|
19
|
+
results.select { |r| r.question.is_a?(Rapidfire::Questions::Radio) }.first
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:json_data) do
|
23
|
+
ActiveSupport::JSON.decode(described_class.new(aggregatable_result).to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "converts to with a hash of results" do
|
27
|
+
expect(json_data["question_type"]).to eq "Rapidfire::Questions::Radio"
|
28
|
+
expect(json_data["question_text"]).to eq aggregatable_result.question.question_text
|
29
|
+
expect(json_data["results"]).not_to be_empty
|
30
|
+
expect(json_data["results"]).to be_a Hash
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when question cannot be aggregated" do
|
34
|
+
let(:aggregatable_result) do
|
35
|
+
results.select { |r| r.question.is_a?(Rapidfire::Questions::Short) }.first
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns an array of results" do
|
39
|
+
expect(json_data["results"]).not_to be_empty
|
40
|
+
expect(json_data["results"]).to be_a Array
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rapidfire::AttemptBuilder do
|
4
|
+
let(:survey) { FactoryGirl.create(:survey) }
|
5
|
+
let(:question1) { FactoryGirl.create(:q_short, survey: survey) }
|
6
|
+
let(:question2) { FactoryGirl.create(:q_long, survey: survey,
|
7
|
+
validation_rules: { presence: "1" }) }
|
8
|
+
|
9
|
+
describe "Creation" do
|
10
|
+
let(:builder) { described_class.new(survey: survey) }
|
11
|
+
before { [question1, question2] }
|
12
|
+
|
13
|
+
it "builds answer group with answers" do
|
14
|
+
expect(builder.answers).not_to be_empty
|
15
|
+
end
|
16
|
+
|
17
|
+
it "builds answers based on number of questions available" do
|
18
|
+
questions = builder.answers.collect { |a| a.question }
|
19
|
+
expect(questions).to match_array([question1, question2])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#save" do
|
24
|
+
let(:question_ids) { survey.questions.map(&:id) }
|
25
|
+
let(:builder) do
|
26
|
+
params = { params: answer_params }.merge(survey: survey)
|
27
|
+
described_class.new(params)
|
28
|
+
end
|
29
|
+
let(:save_answers) { builder.save }
|
30
|
+
|
31
|
+
before do
|
32
|
+
[question1, question2]
|
33
|
+
save_answers
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when all the answers are valid" do
|
37
|
+
let(:answer_params) do
|
38
|
+
{
|
39
|
+
question1.id.to_s => { :answer_text => "short answer" },
|
40
|
+
question2.id.to_s => { :answer_text => "long answer!" }
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns true" do
|
45
|
+
expect(save_answers).to be_truthy
|
46
|
+
end
|
47
|
+
|
48
|
+
it "successfully saves answers" do
|
49
|
+
builder.answers.each do |answer|
|
50
|
+
expect(answer).to be_persisted
|
51
|
+
expect(question_ids).to include(answer.question_id)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "when some of the answers are invalid" do
|
57
|
+
let(:answer_params) do
|
58
|
+
{
|
59
|
+
question1.id.to_s => { :answer_text => "short answer" },
|
60
|
+
question2.id.to_s => { :answer_text => "" }
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns false" do
|
65
|
+
expect(save_answers).to be_falsey
|
66
|
+
end
|
67
|
+
|
68
|
+
it "fails to save those answers" do
|
69
|
+
expect(Rapidfire::Answer.count).to eq(0)
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when requested to save without validations" do
|
73
|
+
let(:save_answers) { builder.save(:validate => false) }
|
74
|
+
|
75
|
+
it "returns true" do
|
76
|
+
expect(save_answers).to be_truthy
|
77
|
+
end
|
78
|
+
|
79
|
+
it "saves all the answers" do
|
80
|
+
builder.answers.each do |answer|
|
81
|
+
expect(answer).to be_persisted
|
82
|
+
expect(question_ids).to include(answer.question_id)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rapidfire::QuestionForm do
|
4
|
+
let(:survey) { FactoryGirl.create(:survey) }
|
5
|
+
|
6
|
+
describe "Creation" do
|
7
|
+
let(:proxy) { described_class.new(survey: survey) }
|
8
|
+
|
9
|
+
it "builds a dummy question" do
|
10
|
+
expect(proxy.question).not_to be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when params are passed" do
|
14
|
+
let(:proxy) { described_class.new(survey: survey, question_text: "Your Bio") }
|
15
|
+
|
16
|
+
it "persists those params" do
|
17
|
+
expect(proxy.question_text).to eq("Your Bio")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when a question is passed" do
|
22
|
+
let(:question) { FactoryGirl.create(:q_checkbox, survey: survey) }
|
23
|
+
let(:proxy) { described_class.new(survey: survey, question: question) }
|
24
|
+
|
25
|
+
it "persists question params" do
|
26
|
+
expect(proxy.type).to eq(question.type)
|
27
|
+
expect(proxy.survey).to eq(question.survey)
|
28
|
+
expect(proxy.question_text).to eq(question.question_text)
|
29
|
+
expect(proxy.answer_options).to eq(question.answer_options)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#save" do
|
35
|
+
before { proxy.save }
|
36
|
+
|
37
|
+
context "creating a new question" do
|
38
|
+
let(:proxy) { described_class.new(params.merge(survey: survey)) }
|
39
|
+
|
40
|
+
context "when question params are valid" do
|
41
|
+
let(:params) do
|
42
|
+
{
|
43
|
+
type: "Rapidfire::Questions::Checkbox",
|
44
|
+
question_text: "Your mood today",
|
45
|
+
answer_options: "good\r\nbad"
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
it "persists the question" do
|
50
|
+
expect(proxy.errors).to be_empty
|
51
|
+
end
|
52
|
+
|
53
|
+
it "creates a question given type" do
|
54
|
+
expect(proxy.question).to be_a(Rapidfire::Questions::Checkbox)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "persists params in created question" do
|
58
|
+
expect(proxy.question.question_text).to eq("Your mood today")
|
59
|
+
expect(proxy.question.options).to match_array(["good", "bad"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "when question params are invalid" do
|
64
|
+
let(:params) do
|
65
|
+
{ type: "Rapidfire::Questions::Checkbox" }
|
66
|
+
end
|
67
|
+
|
68
|
+
it "fails to presist the question" do
|
69
|
+
expect(proxy.errors).not_to be_empty
|
70
|
+
expect(proxy.errors[:question_text]).to include("can't be blank")
|
71
|
+
expect(proxy.errors[:answer_options]).to include("can't be blank")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "updating a question" do
|
77
|
+
let(:question) { FactoryGirl.create(:q_checkbox, survey: survey) }
|
78
|
+
let(:proxy) do
|
79
|
+
proxy_params = params.merge(survey: survey, question: question)
|
80
|
+
described_class.new(proxy_params)
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:params) do
|
84
|
+
{ question_text: "Changing question text" }
|
85
|
+
end
|
86
|
+
|
87
|
+
it "updates the question" do
|
88
|
+
expect(proxy.errors).to be_empty
|
89
|
+
expect(proxy.question.question_text).to eq("Changing question text")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rapidfire::SurveyResults do
|
4
|
+
include Rapidfire::QuestionSpecHelper
|
5
|
+
include Rapidfire::AnswerSpecHelper
|
6
|
+
|
7
|
+
let(:survey) { FactoryGirl.create(:survey) }
|
8
|
+
|
9
|
+
describe '#extract' do
|
10
|
+
before do
|
11
|
+
create_questions(survey)
|
12
|
+
create_answers
|
13
|
+
@survey_results =
|
14
|
+
Rapidfire::SurveyResults.new(survey: survey)
|
15
|
+
@results = @survey_results.extract
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns checkbox answers as a hash containing options as keys and number of answers as values' do
|
19
|
+
answers = @results.find { |result| result.question == @question_checkbox }
|
20
|
+
expect(answers.results['hindi']).to eq(3)
|
21
|
+
expect(answers.results['telugu']).to eq(1)
|
22
|
+
expect(answers.results['kannada']).to eq(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns "date" type answers as an array' do
|
26
|
+
answers = @results.find { |result| result.question == @question_date }
|
27
|
+
expect(answers.results).to be_a(Array)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns "long" type answers as an array' do
|
31
|
+
answers = @results.find { |result| result.question == @question_long }
|
32
|
+
expect(answers.results).to be_a(Array)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns "numeric" type answers as an array' do
|
36
|
+
answers = @results.find { |result| result.question == @question_numeric }
|
37
|
+
expect(answers.results).to be_a(Array)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns "short" type answers as an array' do
|
41
|
+
answers = @results.find { |result| result.question == @question_short }
|
42
|
+
expect(answers.results).to be_a(Array)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns "radio" type answers as a hash containing options as keys and number of answers as values' do
|
46
|
+
answers = @results.find { |result| result.question == @question_radio }
|
47
|
+
expect(answers.results['male']).to eq(1)
|
48
|
+
expect(answers.results['female']).to eq(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns "select" type answers as a hash containing options as keys and number of answers as values' do
|
52
|
+
answers = @results.find { |result| result.question == @question_select }
|
53
|
+
expect(answers.results['mac']).to eq(2)
|
54
|
+
expect(answers.results['windows']).to eq(1)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns "short" type answers as an array' do
|
58
|
+
answers = @results.find { |result| result.question == @question_short }
|
59
|
+
expect(answers.results).to be_a(Array)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
|
6
|
+
require 'capybara/rails'
|
7
|
+
require 'capybara-webkit'
|
8
|
+
require 'factory_girl_rails'
|
9
|
+
require 'database_cleaner'
|
10
|
+
require 'shoulda'
|
11
|
+
|
12
|
+
Capybara.javascript_driver = :webkit
|
13
|
+
|
14
|
+
RAPIDFIRE_ROOT = File.join(File.dirname(__FILE__), '..')
|
15
|
+
|
16
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
17
|
+
# in spec/support/ and its subdirectories.
|
18
|
+
Dir[File.join(RAPIDFIRE_ROOT, "spec/support/**/*.rb")].each { |f| require f }
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# ## Mock Framework
|
22
|
+
#
|
23
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
24
|
+
#
|
25
|
+
# config.mock_with :mocha
|
26
|
+
# config.mock_with :flexmock
|
27
|
+
# config.mock_with :rr
|
28
|
+
|
29
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
30
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
31
|
+
|
32
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
33
|
+
# examples within a transaction, remove the following line or assign false
|
34
|
+
# instead of true.
|
35
|
+
# config.use_transactional_fixtures = true
|
36
|
+
|
37
|
+
# If true, the base class of anonymous controllers will be inferred
|
38
|
+
# automatically. This will be the default behavior in future versions of
|
39
|
+
# rspec-rails.
|
40
|
+
config.infer_base_class_for_anonymous_controllers = false
|
41
|
+
|
42
|
+
# Run specs in random order to surface order dependencies. If you find an
|
43
|
+
# order dependency and want to debug it, you can fix the order by providing
|
44
|
+
# the seed, which is printed after each run.
|
45
|
+
# --seed 1234
|
46
|
+
config.order = "random"
|
47
|
+
|
48
|
+
config.before do
|
49
|
+
DatabaseCleaner.strategy =
|
50
|
+
Capybara.current_driver == :rack_test ? :transaction : :truncation
|
51
|
+
DatabaseCleaner.start
|
52
|
+
end
|
53
|
+
|
54
|
+
config.after do
|
55
|
+
DatabaseCleaner.clean
|
56
|
+
end
|
57
|
+
|
58
|
+
# rspec-rails 3 will no longer automatically infer an example group's spec type
|
59
|
+
# from the file location. You can explicitly opt-in to the feature using this
|
60
|
+
# config option.
|
61
|
+
# To explicitly tag specs without using automatic inference, set the `:type`
|
62
|
+
# metadata manually:
|
63
|
+
#
|
64
|
+
# describe ThingsController, :type => :controller do
|
65
|
+
# # Equivalent to being in spec/controllers
|
66
|
+
# end
|
67
|
+
config.infer_spec_type_from_file_location!
|
68
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Rapidfire
|
2
|
+
module AnswerSpecHelper
|
3
|
+
def create_answers
|
4
|
+
FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => 'hindi')
|
5
|
+
FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\ntelugu")
|
6
|
+
FactoryGirl.create(:answer, :question => @question_checkbox, :answer_text => "hindi\r\nkannada")
|
7
|
+
|
8
|
+
FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'mac')
|
9
|
+
FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'mac')
|
10
|
+
FactoryGirl.create(:answer, :question => @question_select, :answer_text => 'windows')
|
11
|
+
|
12
|
+
FactoryGirl.create(:answer, :question => @question_radio, :answer_text => 'male')
|
13
|
+
FactoryGirl.create(:answer, :question => @question_radio, :answer_text => 'female')
|
14
|
+
|
15
|
+
3.times do
|
16
|
+
FactoryGirl.create(:answer, :question => @question_date, :answer_text => Date.today.to_s)
|
17
|
+
FactoryGirl.create(:answer, :question => @question_long, :answer_text => 'my bio goes on and on!')
|
18
|
+
FactoryGirl.create(:answer, :question => @question_numeric, :answer_text => 999)
|
19
|
+
FactoryGirl.create(:answer, :question => @question_short, :answer_text => 'this is cool')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Rapidfire
|
2
|
+
module QuestionSpecHelper
|
3
|
+
def create_questions(survey)
|
4
|
+
@question_checkbox = FactoryGirl.create(:q_checkbox, :survey => survey)
|
5
|
+
@question_date = FactoryGirl.create(:q_date, :survey => survey)
|
6
|
+
@question_long = FactoryGirl.create(:q_long, :survey => survey)
|
7
|
+
@question_numeric = FactoryGirl.create(:q_numeric, :survey => survey)
|
8
|
+
@question_radio = FactoryGirl.create(:q_radio, :survey => survey)
|
9
|
+
@question_select = FactoryGirl.create(:q_select, :survey => survey)
|
10
|
+
@question_short = FactoryGirl.create(:q_short, :survey => survey)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rake'
|
3
|
+
load File.expand_path('../../../lib/tasks/change_delimiter_to_srsn.rake', __FILE__)
|
4
|
+
|
5
|
+
|
6
|
+
describe 'rapidfire:change_delimiter_from_comma_to_srsn' do
|
7
|
+
before do
|
8
|
+
Rake::Task.define_task(:environment)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'converts select,radio and checkbox answer options delimiter from , to \r\n' do
|
12
|
+
survey = FactoryGirl.create(:survey)
|
13
|
+
q_checkbox = FactoryGirl.create(:q_checkbox, survey: survey,
|
14
|
+
answer_options: 'one,two,three')
|
15
|
+
q_radio = FactoryGirl.create(:q_radio, survey: survey,
|
16
|
+
answer_options: 'hello,world')
|
17
|
+
q_select = FactoryGirl.create(:q_select, survey: survey,
|
18
|
+
answer_options: 'new,old,historic,')
|
19
|
+
|
20
|
+
q_date = FactoryGirl.create(:q_date, survey: survey)
|
21
|
+
q_long = FactoryGirl.create(:q_long, survey: survey)
|
22
|
+
q_numeric = FactoryGirl.create(:q_numeric, survey: survey)
|
23
|
+
q_short = FactoryGirl.create(:q_short, survey: survey)
|
24
|
+
|
25
|
+
Rake::Task['rapidfire:change_delimiter_from_comma_to_srsn'].invoke
|
26
|
+
|
27
|
+
expect(q_checkbox.reload.answer_options).to eq "one\r\ntwo\r\nthree"
|
28
|
+
expect(q_radio.reload.answer_options).to eq "hello\r\nworld"
|
29
|
+
expect(q_select.reload.answer_options).to eq "new\r\nold\r\nhistoric"
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rapidfire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuva Kumar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: quiet_assets
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec-rails
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,15 +176,14 @@ files:
|
|
190
176
|
- Rakefile
|
191
177
|
- app/assets/javascripts/rapidfire/application.js
|
192
178
|
- app/assets/stylesheets/rapidfire/application.css
|
193
|
-
- app/controllers/rapidfire/answer_groups_controller.rb
|
194
179
|
- app/controllers/rapidfire/application_controller.rb
|
195
|
-
- app/controllers/rapidfire/
|
180
|
+
- app/controllers/rapidfire/attempts_controller.rb
|
196
181
|
- app/controllers/rapidfire/questions_controller.rb
|
182
|
+
- app/controllers/rapidfire/surveys_controller.rb
|
197
183
|
- app/helpers/rapidfire/application_helper.rb
|
198
184
|
- app/models/rapidfire/answer.rb
|
199
|
-
- app/models/rapidfire/
|
185
|
+
- app/models/rapidfire/attempt.rb
|
200
186
|
- app/models/rapidfire/question.rb
|
201
|
-
- app/models/rapidfire/question_group.rb
|
202
187
|
- app/models/rapidfire/questions/checkbox.rb
|
203
188
|
- app/models/rapidfire/questions/date.rb
|
204
189
|
- app/models/rapidfire/questions/long.rb
|
@@ -206,13 +191,13 @@ files:
|
|
206
191
|
- app/models/rapidfire/questions/radio.rb
|
207
192
|
- app/models/rapidfire/questions/select.rb
|
208
193
|
- app/models/rapidfire/questions/short.rb
|
194
|
+
- app/models/rapidfire/survey.rb
|
209
195
|
- app/serializers/rapidfire/question_result_serializer.rb
|
210
|
-
- app/services/rapidfire/
|
196
|
+
- app/services/rapidfire/attempt_builder.rb
|
211
197
|
- app/services/rapidfire/base_service.rb
|
212
198
|
- app/services/rapidfire/question_form.rb
|
213
|
-
- app/services/rapidfire/question_group_results.rb
|
214
199
|
- app/services/rapidfire/question_result.rb
|
215
|
-
- app/
|
200
|
+
- app/services/rapidfire/survey_results.rb
|
216
201
|
- app/views/rapidfire/answers/_checkbox.html.erb
|
217
202
|
- app/views/rapidfire/answers/_date.html.erb
|
218
203
|
- app/views/rapidfire/answers/_errors.html.erb
|
@@ -221,28 +206,89 @@ files:
|
|
221
206
|
- app/views/rapidfire/answers/_radio.html.erb
|
222
207
|
- app/views/rapidfire/answers/_select.html.erb
|
223
208
|
- app/views/rapidfire/answers/_short.html.erb
|
224
|
-
- app/views/rapidfire/
|
225
|
-
- app/views/rapidfire/question_groups/_question_group.html.erb
|
226
|
-
- app/views/rapidfire/question_groups/index.html.erb
|
227
|
-
- app/views/rapidfire/question_groups/new.html.erb
|
228
|
-
- app/views/rapidfire/question_groups/results.html.erb
|
209
|
+
- app/views/rapidfire/attempts/new.html.erb
|
229
210
|
- app/views/rapidfire/questions/_form.html.erb
|
230
211
|
- app/views/rapidfire/questions/_question.html.erb
|
231
212
|
- app/views/rapidfire/questions/edit.html.erb
|
232
213
|
- app/views/rapidfire/questions/index.html.erb
|
233
214
|
- app/views/rapidfire/questions/new.html.erb
|
215
|
+
- app/views/rapidfire/surveys/_form.html.erb
|
216
|
+
- app/views/rapidfire/surveys/_survey.html.erb
|
217
|
+
- app/views/rapidfire/surveys/index.html.erb
|
218
|
+
- app/views/rapidfire/surveys/new.html.erb
|
219
|
+
- app/views/rapidfire/surveys/results.html.erb
|
234
220
|
- config/database.yml
|
235
221
|
- config/routes.rb
|
236
222
|
- db/migrate/20130502170733_create_rapidfire_question_groups.rb
|
237
223
|
- db/migrate/20130502195310_create_rapidfire_questions.rb
|
238
224
|
- db/migrate/20130502195415_create_rapidfire_answer_groups.rb
|
239
225
|
- db/migrate/20130502195504_create_rapidfire_answers.rb
|
226
|
+
- lib/generators/rapidfire/templates/migrations/rename_answer_groups_and_question_groups.rb
|
227
|
+
- lib/generators/rapidfire/upgrade_migration_generator.rb
|
240
228
|
- lib/generators/rapidfire/views_generator.rb
|
241
229
|
- lib/rapidfire.rb
|
242
230
|
- lib/rapidfire/engine.rb
|
243
231
|
- lib/rapidfire/version.rb
|
244
232
|
- lib/tasks/change_delimiter_to_srsn.rake
|
233
|
+
- lib/tasks/rapidfire.rake
|
245
234
|
- lib/tasks/rapidfire_tasks.rake
|
235
|
+
- spec/controllers/rapidfire/attempts_controller_spec.rb
|
236
|
+
- spec/dummy/README.rdoc
|
237
|
+
- spec/dummy/Rakefile
|
238
|
+
- spec/dummy/app/assets/javascripts/application.js
|
239
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
240
|
+
- spec/dummy/app/controllers/application_controller.rb
|
241
|
+
- spec/dummy/app/helpers/application_helper.rb
|
242
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
243
|
+
- spec/dummy/config.ru
|
244
|
+
- spec/dummy/config/application.rb
|
245
|
+
- spec/dummy/config/boot.rb
|
246
|
+
- spec/dummy/config/database.yml
|
247
|
+
- spec/dummy/config/environment.rb
|
248
|
+
- spec/dummy/config/environments/development.rb
|
249
|
+
- spec/dummy/config/environments/production.rb
|
250
|
+
- spec/dummy/config/environments/test.rb
|
251
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
252
|
+
- spec/dummy/config/initializers/inflections.rb
|
253
|
+
- spec/dummy/config/initializers/mime_types.rb
|
254
|
+
- spec/dummy/config/initializers/secret_token.rb
|
255
|
+
- spec/dummy/config/initializers/session_store.rb
|
256
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
257
|
+
- spec/dummy/config/locales/en.yml
|
258
|
+
- spec/dummy/config/routes.rb
|
259
|
+
- spec/dummy/db/development.sqlite3
|
260
|
+
- spec/dummy/db/schema.rb
|
261
|
+
- spec/dummy/db/test.sqlite3
|
262
|
+
- spec/dummy/log/development.log
|
263
|
+
- spec/dummy/log/test.log
|
264
|
+
- spec/dummy/public/404.html
|
265
|
+
- spec/dummy/public/422.html
|
266
|
+
- spec/dummy/public/500.html
|
267
|
+
- spec/dummy/public/favicon.ico
|
268
|
+
- spec/dummy/script/rails
|
269
|
+
- spec/factories/answers_factory.rb
|
270
|
+
- spec/factories/attempts_factory.rb
|
271
|
+
- spec/factories/questions_factory.rb
|
272
|
+
- spec/factories/surveys_factory.rb
|
273
|
+
- spec/features/rapidfire/answering_questions_spec.rb
|
274
|
+
- spec/features/rapidfire/managing_questions_spec.rb
|
275
|
+
- spec/features/rapidfire/managing_surveys_spec.rb
|
276
|
+
- spec/models/rapidfire/answer_spec.rb
|
277
|
+
- spec/models/rapidfire/attempt_spec.rb
|
278
|
+
- spec/models/rapidfire/question_spec.rb
|
279
|
+
- spec/models/rapidfire/questions/checkbox_spec.rb
|
280
|
+
- spec/models/rapidfire/questions/date_spec.rb
|
281
|
+
- spec/models/rapidfire/questions/numeric_spec.rb
|
282
|
+
- spec/models/rapidfire/questions/select_spec.rb
|
283
|
+
- spec/models/rapidfire/survey_spec.rb
|
284
|
+
- spec/serializers/rapidfire/question_result_serializer_spec.rb
|
285
|
+
- spec/services/rapidfire/attempt_builder_spec.rb
|
286
|
+
- spec/services/rapidfire/question_form_spec.rb
|
287
|
+
- spec/services/rapidfire/survey_results_spec.rb
|
288
|
+
- spec/spec_helper.rb
|
289
|
+
- spec/support/rapidfire/answer_spec_helper.rb
|
290
|
+
- spec/support/rapidfire/question_spec_helper.rb
|
291
|
+
- spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb
|
246
292
|
homepage: https://github.com/code-mancers/rapidfire
|
247
293
|
licenses: []
|
248
294
|
metadata: {}
|
@@ -264,8 +310,65 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
310
|
version: '0'
|
265
311
|
requirements: []
|
266
312
|
rubyforge_project:
|
267
|
-
rubygems_version: 2.
|
313
|
+
rubygems_version: 2.6.6
|
268
314
|
signing_key:
|
269
315
|
specification_version: 4
|
270
316
|
summary: Surveys made easy.
|
271
|
-
test_files:
|
317
|
+
test_files:
|
318
|
+
- spec/controllers/rapidfire/attempts_controller_spec.rb
|
319
|
+
- spec/dummy/app/assets/javascripts/application.js
|
320
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
321
|
+
- spec/dummy/app/controllers/application_controller.rb
|
322
|
+
- spec/dummy/app/helpers/application_helper.rb
|
323
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
324
|
+
- spec/dummy/config/application.rb
|
325
|
+
- spec/dummy/config/boot.rb
|
326
|
+
- spec/dummy/config/database.yml
|
327
|
+
- spec/dummy/config/environment.rb
|
328
|
+
- spec/dummy/config/environments/development.rb
|
329
|
+
- spec/dummy/config/environments/production.rb
|
330
|
+
- spec/dummy/config/environments/test.rb
|
331
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
332
|
+
- spec/dummy/config/initializers/inflections.rb
|
333
|
+
- spec/dummy/config/initializers/mime_types.rb
|
334
|
+
- spec/dummy/config/initializers/secret_token.rb
|
335
|
+
- spec/dummy/config/initializers/session_store.rb
|
336
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
337
|
+
- spec/dummy/config/locales/en.yml
|
338
|
+
- spec/dummy/config/routes.rb
|
339
|
+
- spec/dummy/config.ru
|
340
|
+
- spec/dummy/db/development.sqlite3
|
341
|
+
- spec/dummy/db/schema.rb
|
342
|
+
- spec/dummy/db/test.sqlite3
|
343
|
+
- spec/dummy/log/development.log
|
344
|
+
- spec/dummy/log/test.log
|
345
|
+
- spec/dummy/public/404.html
|
346
|
+
- spec/dummy/public/422.html
|
347
|
+
- spec/dummy/public/500.html
|
348
|
+
- spec/dummy/public/favicon.ico
|
349
|
+
- spec/dummy/Rakefile
|
350
|
+
- spec/dummy/README.rdoc
|
351
|
+
- spec/dummy/script/rails
|
352
|
+
- spec/factories/answers_factory.rb
|
353
|
+
- spec/factories/attempts_factory.rb
|
354
|
+
- spec/factories/questions_factory.rb
|
355
|
+
- spec/factories/surveys_factory.rb
|
356
|
+
- spec/features/rapidfire/answering_questions_spec.rb
|
357
|
+
- spec/features/rapidfire/managing_questions_spec.rb
|
358
|
+
- spec/features/rapidfire/managing_surveys_spec.rb
|
359
|
+
- spec/models/rapidfire/answer_spec.rb
|
360
|
+
- spec/models/rapidfire/attempt_spec.rb
|
361
|
+
- spec/models/rapidfire/question_spec.rb
|
362
|
+
- spec/models/rapidfire/questions/checkbox_spec.rb
|
363
|
+
- spec/models/rapidfire/questions/date_spec.rb
|
364
|
+
- spec/models/rapidfire/questions/numeric_spec.rb
|
365
|
+
- spec/models/rapidfire/questions/select_spec.rb
|
366
|
+
- spec/models/rapidfire/survey_spec.rb
|
367
|
+
- spec/serializers/rapidfire/question_result_serializer_spec.rb
|
368
|
+
- spec/services/rapidfire/attempt_builder_spec.rb
|
369
|
+
- spec/services/rapidfire/question_form_spec.rb
|
370
|
+
- spec/services/rapidfire/survey_results_spec.rb
|
371
|
+
- spec/spec_helper.rb
|
372
|
+
- spec/support/rapidfire/answer_spec_helper.rb
|
373
|
+
- spec/support/rapidfire/question_spec_helper.rb
|
374
|
+
- spec/tasks/change_delimiter_from_comma_to_srsn_spec.rb
|