surveyor 0.22.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +83 -0
- data/Gemfile.rails_version +7 -1
- data/README.md +114 -16
- data/Rakefile +15 -9
- data/app/inputs/quiet_input.rb +5 -0
- data/app/inputs/surveyor_check_boxes_input.rb +35 -0
- data/app/inputs/surveyor_radio_input.rb +18 -0
- data/app/views/partials/_answer.html.haml +4 -4
- data/app/views/partials/_question.html.haml +7 -7
- data/app/views/partials/_question_group.html.haml +9 -8
- data/app/views/surveyor/export.json.rabl +28 -25
- data/app/views/surveyor/new.html.haml +8 -5
- data/app/views/surveyor/show.json.rabl +3 -2
- data/ci-exec.sh +13 -7
- data/cucumber.yml +3 -3
- data/doc/REPRESENTATIONS.md +34 -0
- data/doc/api_id_schema.json +7 -0
- data/doc/response_set_schema.json +54 -0
- data/doc/surveyor question combinations.png +0 -0
- data/doc/surveyor_timestamp_schema.json +9 -0
- data/features/ajax_submissions.feature +140 -0
- data/features/export_to_json.feature +182 -34
- data/features/no_duplicates.feature +110 -0
- data/features/show_survey.feature +1 -1
- data/features/step_definitions/parser_steps.rb +25 -2
- data/features/step_definitions/surveyor_steps.rb +145 -20
- data/features/step_definitions/ui_steps.rb +3 -0
- data/features/support/database_cleaner.rb +16 -0
- data/features/support/env.rb +21 -17
- data/features/support/simultaneous_ajax.rb +101 -0
- data/features/support/single_quit_selenium_driver.rb +23 -0
- data/features/support/slow_updates.rb +18 -0
- data/features/surveyor.feature +174 -44
- data/features/surveyor_dependencies.feature +80 -39
- data/features/surveyor_parser.feature +114 -20
- data/features/z_redcap_parser.feature +0 -1
- data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/next.gif +0 -0
- data/lib/{generators/surveyor/templates/public → assets}/images/surveyor/prev.gif +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/lib/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ef8c08_256x240.png +0 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/surveyor → assets/images}/ui-icons_ffffff_256x240.png +0 -0
- data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui-timepicker-addon.js +23 -23
- data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery-ui.js +125 -125
- data/lib/assets/javascripts/surveyor/jquery.selectToUISlider.js +240 -0
- data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.surveyor.js +52 -57
- data/lib/{generators/surveyor/templates/public → assets}/javascripts/surveyor/jquery.tools.min.js +7 -7
- data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/dateinput.css +13 -13
- data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui-timepicker-addon.css +0 -0
- data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/jquery-ui.custom.css +17 -17
- data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/reset.css +1 -1
- data/lib/{generators/surveyor/templates/public → assets}/stylesheets/surveyor/results.css +0 -0
- data/lib/assets/stylesheets/surveyor/ui.slider.extras.css +110 -0
- data/lib/{generators/surveyor/templates/public/stylesheets/sass → assets/stylesheets}/surveyor.sass +15 -7
- data/lib/generators/surveyor/custom_generator.rb +3 -2
- data/lib/generators/surveyor/install_generator.rb +59 -17
- data/lib/generators/surveyor/templates/app/assets/javascripts/surveyor_all.js +5 -0
- data/lib/generators/surveyor/templates/app/assets/stylesheets/surveyor_all.css +9 -0
- data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +2 -1
- data/lib/generators/surveyor/templates/app/views/layouts/surveyor_custom.html.erb +1 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_es.yml +1 -0
- data/lib/generators/surveyor/templates/config/locales/surveyor_he.yml +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_id_to_question_groups.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_api_ids_to_response_sets_and_responses.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_correct_answer_id_to_questions.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_default_value_to_answers.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_order_to_surveys.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_display_type_to_answers.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_response_sets.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_index_to_surveys.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_section_id_to_responses.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_index_on_access_code_and_version_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/add_unique_indicies.rb +3 -2
- data/lib/generators/surveyor/templates/db/migrate/add_version_to_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/api_ids_must_be_unique.rb +23 -0
- data/lib/generators/surveyor/templates/db/migrate/create_answers.rb +6 -5
- data/lib/generators/surveyor/templates/db/migrate/create_dependencies.rb +2 -1
- data/lib/generators/surveyor/templates/db/migrate/create_dependency_conditions.rb +2 -1
- data/lib/generators/surveyor/templates/db/migrate/create_question_groups.rb +5 -4
- data/lib/generators/surveyor/templates/db/migrate/create_questions.rb +4 -3
- data/lib/generators/surveyor/templates/db/migrate/create_response_sets.rb +1 -0
- data/lib/generators/surveyor/templates/db/migrate/create_responses.rb +10 -9
- data/lib/generators/surveyor/templates/db/migrate/create_survey_sections.rb +5 -4
- data/lib/generators/surveyor/templates/db/migrate/create_surveys.rb +4 -3
- data/lib/generators/surveyor/templates/db/migrate/create_validation_conditions.rb +5 -4
- data/lib/generators/surveyor/templates/db/migrate/create_validations.rb +3 -2
- data/lib/generators/surveyor/templates/db/migrate/drop_unique_index_on_access_code_in_surveys.rb +10 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_api_ids_on_question_group.rb +22 -0
- data/lib/generators/surveyor/templates/db/migrate/update_blank_versions_on_surveys.rb +13 -0
- data/lib/generators/surveyor/templates/surveys/date_survey.rb +1 -0
- data/lib/generators/surveyor/templates/surveys/kitchen_sink_survey.rb +54 -24
- data/lib/generators/surveyor/templates/surveys/quiz.rb +1 -0
- data/lib/generators/surveyor/templates/{public/stylesheets/sass → vendor/assets/stylesheets}/custom.sass +1 -1
- data/lib/surveyor/common.rb +16 -31
- data/lib/surveyor/engine.rb +2 -4
- data/lib/surveyor/helpers/asset_pipeline.rb +13 -0
- data/lib/surveyor/helpers/formtastic_custom_input.rb +17 -0
- data/lib/surveyor/helpers/surveyor_helper_methods.rb +10 -8
- data/lib/surveyor/models/answer_methods.rb +3 -0
- data/lib/surveyor/models/dependency_condition_methods.rb +27 -28
- data/lib/surveyor/models/dependency_methods.rb +3 -0
- data/lib/surveyor/models/question_group_methods.rb +3 -0
- data/lib/surveyor/models/question_methods.rb +10 -7
- data/lib/surveyor/models/response_methods.rb +16 -0
- data/lib/surveyor/models/response_set_methods.rb +71 -64
- data/lib/surveyor/models/survey_methods.rb +19 -28
- data/lib/surveyor/models/survey_section_methods.rb +3 -0
- data/lib/surveyor/models/validation_condition_methods.rb +4 -2
- data/lib/surveyor/models/validation_methods.rb +3 -0
- data/lib/surveyor/parser.rb +198 -148
- data/lib/surveyor/redcap_parser.rb +120 -80
- data/lib/surveyor/surveyor_controller_methods.rb +86 -37
- data/lib/surveyor/version.rb +2 -2
- data/lib/surveyor.rb +5 -6
- data/lib/tasks/surveyor_tasks.rake +19 -7
- data/spec/controllers/surveyor_controller_spec.rb +166 -92
- data/spec/factories.rb +33 -32
- data/spec/helpers/formtastic_custom_input_spec.rb +16 -0
- data/spec/lib/common_spec.rb +0 -39
- data/spec/lib/redcap_parser_spec.rb +24 -24
- data/spec/models/answer_spec.rb +12 -0
- data/spec/models/dependency_condition_spec.rb +279 -323
- data/spec/models/dependency_spec.rb +10 -0
- data/spec/models/question_group_spec.rb +12 -0
- data/spec/models/question_spec.rb +12 -0
- data/spec/models/response_set_spec.rb +189 -139
- data/spec/models/response_spec.rb +60 -0
- data/spec/models/survey_section_spec.rb +9 -0
- data/spec/models/survey_spec.rb +72 -9
- data/spec/models/validation_condition_spec.rb +9 -1
- data/spec/models/validation_spec.rb +10 -0
- data/spec/spec_helper.rb +25 -6
- data/surveyor.gemspec +5 -4
- metadata +332 -291
- data/features/step_definitions/common_steps.rb +0 -3
- data/lib/formtastic/surveyor_builder.rb +0 -82
- data/lib/generators/surveyor/templates/public/javascripts/surveyor/jquery.blockUI.js +0 -499
@@ -49,7 +49,15 @@ describe ValidationCondition do
|
|
49
49
|
@validation_condition.operator = "#"
|
50
50
|
@validation_condition.should have(1).error_on(:operator)
|
51
51
|
end
|
52
|
-
|
52
|
+
it "should protect timestamps" do
|
53
|
+
saved_attrs = @validation_condition.attributes
|
54
|
+
if defined? ActiveModel::MassAssignmentSecurity::Error
|
55
|
+
lambda {@validation_condition.update_attributes(:created_at => 3.days.ago, :updated_at => 3.hours.ago)}.should raise_error(ActiveModel::MassAssignmentSecurity::Error)
|
56
|
+
else
|
57
|
+
@validation_condition.attributes = {:created_at => 3.days.ago, :updated_at => 3.hours.ago} # automatically protected by Rails
|
58
|
+
end
|
59
|
+
@validation_condition.attributes.should == saved_attrs
|
60
|
+
end
|
53
61
|
end
|
54
62
|
|
55
63
|
describe ValidationCondition, "validating responses" do
|
@@ -30,6 +30,16 @@ describe Validation do
|
|
30
30
|
@validation.rule = "a and b"
|
31
31
|
@validation.should have(1).error_on(:rule)
|
32
32
|
end
|
33
|
+
it "should protect timestamps" do
|
34
|
+
saved_attrs = @validation.attributes
|
35
|
+
if defined? ActiveModel::MassAssignmentSecurity::Error
|
36
|
+
lambda {@validation.update_attributes(:created_at => 3.days.ago, :updated_at => 3.hours.ago)}.should raise_error(ActiveModel::MassAssignmentSecurity::Error)
|
37
|
+
else
|
38
|
+
@validation.attributes = {:created_at => 3.days.ago, :updated_at => 3.hours.ago} # automatically protected by Rails
|
39
|
+
@validation.attributes = {:created_at => 3.days.ago, :updated_at => 3.hours.ago} # automatically protected by Rails
|
40
|
+
end
|
41
|
+
@validation.attributes.should == saved_attrs
|
42
|
+
end
|
33
43
|
end
|
34
44
|
describe Validation, "reporting its status" do
|
35
45
|
def test_var(vhash, vchashes, ahash, rhash)
|
data/spec/spec_helper.rb
CHANGED
@@ -8,11 +8,15 @@ end
|
|
8
8
|
require 'rspec/rails'
|
9
9
|
require 'factories'
|
10
10
|
|
11
|
+
require 'database_cleaner'
|
12
|
+
|
11
13
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
12
14
|
# in spec/support/ and its subdirectories.
|
13
15
|
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
14
16
|
|
15
17
|
RSpec.configure do |config|
|
18
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
|
+
|
16
20
|
# == Mock Framework
|
17
21
|
#
|
18
22
|
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
@@ -22,11 +26,26 @@ RSpec.configure do |config|
|
|
22
26
|
# config.mock_with :rr
|
23
27
|
config.mock_with :rspec
|
24
28
|
|
25
|
-
|
26
|
-
|
29
|
+
## Database Cleaner
|
30
|
+
|
31
|
+
config.before(:suite) do
|
32
|
+
DatabaseCleaner.strategy = :transaction
|
33
|
+
DatabaseCleaner.clean_with(:truncation)
|
34
|
+
end
|
35
|
+
|
36
|
+
config.before(:each, :clean_with_truncation) do
|
37
|
+
DatabaseCleaner.strategy = :truncation
|
38
|
+
end
|
39
|
+
|
40
|
+
config.after(:each, :clean_with_truncation) do
|
41
|
+
DatabaseCleaner.strategy = :transaction
|
42
|
+
end
|
43
|
+
|
44
|
+
config.before(:each) do
|
45
|
+
DatabaseCleaner.start
|
46
|
+
end
|
27
47
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
config.use_transactional_fixtures = true
|
48
|
+
config.after(:each) do
|
49
|
+
DatabaseCleaner.clean
|
50
|
+
end
|
32
51
|
end
|
data/surveyor.gemspec
CHANGED
@@ -21,14 +21,14 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency('haml', '~> 3.1.3')
|
22
22
|
s.add_dependency('sass')
|
23
23
|
s.add_dependency('fastercsv', '~> 1.5.4')
|
24
|
-
s.add_dependency('formtastic', '~> 1.
|
24
|
+
s.add_dependency('formtastic', '~> 2.1.0')
|
25
25
|
s.add_dependency('uuidtools', '~> 2.1')
|
26
26
|
s.add_dependency('mustache', '0.99.4')
|
27
|
-
s.add_dependency('rabl', '~>0.6.
|
27
|
+
s.add_dependency('rabl', '~>0.6.13')
|
28
28
|
|
29
29
|
s.add_development_dependency('yard')
|
30
|
-
s.add_development_dependency('rake', '0.
|
31
|
-
s.add_development_dependency('rspec-rails', '~> 2.
|
30
|
+
s.add_development_dependency('rake', '>= 0.9.2')
|
31
|
+
s.add_development_dependency('rspec-rails', '~> 2.9.0')
|
32
32
|
s.add_development_dependency('bundler', '~> 1.0', '>= 1.0.21')
|
33
33
|
s.add_development_dependency('factory_girl', '~> 2.1.2')
|
34
34
|
s.add_development_dependency('sqlite3')
|
@@ -37,5 +37,6 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.add_development_dependency('launchy', '~> 2.0.5')
|
38
38
|
s.add_development_dependency('capybara', '~> 1.1.1')
|
39
39
|
s.add_development_dependency('ci_reporter', '1.6.6')
|
40
|
+
s.add_development_dependency('json_spec', '~> 1.0.3')
|
40
41
|
end
|
41
42
|
|