upgrade_surveyor_gui 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +46 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/MIT-LICENSE +20 -0
- data/README.md +244 -0
- data/Rakefile +66 -0
- data/app/controllers/surveyor_controller.rb +89 -0
- data/app/controllers/surveyor_gui/answers_controller.rb +3 -0
- data/app/controllers/surveyor_gui/application_controller.rb +3 -0
- data/app/controllers/surveyor_gui/dependencys_controller.rb +286 -0
- data/app/controllers/surveyor_gui/question_groups_controller.rb +90 -0
- data/app/controllers/surveyor_gui/questions_controller.rb +187 -0
- data/app/controllers/surveyor_gui/reports_controller.rb +339 -0
- data/app/controllers/surveyor_gui/responses_controller.rb +41 -0
- data/app/controllers/surveyor_gui/survey_controller.rb +16 -0
- data/app/controllers/surveyor_gui/survey_sections_controller.rb +80 -0
- data/app/controllers/surveyor_gui/surveyforms_controller.rb +4 -0
- data/app/facades/report_formatter.rb +46 -0
- data/app/facades/report_preview_wrapper.rb +11 -0
- data/app/facades/report_response_generator.rb +147 -0
- data/app/helpers/surveyor_gui/application_helper.rb +2 -0
- data/app/helpers/surveyor_gui/dependencys_helper.rb +5 -0
- data/app/helpers/surveyor_gui/question_groups_helper.rb +3 -0
- data/app/helpers/surveyor_gui/questions_helper.rb +22 -0
- data/app/helpers/surveyor_gui/reports_helper.rb +19 -0
- data/app/helpers/surveyor_gui/surveyforms_helper.rb +164 -0
- data/app/helpers/surveyor_helper.rb +4 -0
- data/app/inputs/currency_input.rb +5 -0
- data/app/inputs/date_picker_input.rb +7 -0
- data/app/inputs/datetime_picker_input.rb +5 -0
- data/app/inputs/percent_input.rb +5 -0
- data/app/inputs/time_picker_input.rb +5 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/answer.rb +4 -0
- data/app/models/column.rb +3 -0
- data/app/models/dependency.rb +4 -0
- data/app/models/dependency_condition.rb +4 -0
- data/app/models/permitted_params_decorator.rb +80 -0
- data/app/models/question.rb +4 -0
- data/app/models/question_group.rb +4 -0
- data/app/models/question_group_tracker.rb +19 -0
- data/app/models/question_type.rb +7 -0
- data/app/models/response.rb +4 -0
- data/app/models/response_set.rb +4 -0
- data/app/models/row.rb +3 -0
- data/app/models/survey.rb +4 -0
- data/app/models/survey_section.rb +4 -0
- data/app/models/surveyform.rb +103 -0
- data/app/uploaders/blob_uploader.rb +48 -0
- data/app/views/layouts/surveyor_gui/application.html.erb +14 -0
- data/app/views/layouts/surveyor_gui/surveyor_gui_blank.html.erb +13 -0
- data/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
- data/app/views/layouts/surveyor_gui/surveyor_modified.html.erb +14 -0
- data/app/views/partials/_answer.html.haml +33 -0
- data/app/views/partials/_question.html.haml +33 -0
- data/app/views/partials/_question_group.html.haml +73 -0
- data/app/views/partials/_section.html.haml +13 -0
- data/app/views/surveyor/edit.html.haml +21 -0
- data/app/views/surveyor_gui/dependencys/_column.html.erb +1 -0
- data/app/views/surveyor_gui/dependencys/_dependency.html.erb +22 -0
- data/app/views/surveyor_gui/dependencys/_dependency_condition_fields.html.erb +48 -0
- data/app/views/surveyor_gui/dependencys/_form.html.erb +20 -0
- data/app/views/surveyor_gui/dependencys/blank.html.erb +0 -0
- data/app/views/surveyor_gui/dependencys/edit.html.erb +1 -0
- data/app/views/surveyor_gui/dependencys/new.html.erb +1 -0
- data/app/views/surveyor_gui/partials/_url_helpers.html.erb +5 -0
- data/app/views/surveyor_gui/question_groups/_form.html.erb +57 -0
- data/app/views/surveyor_gui/question_groups/_group_inline_field.html.erb +21 -0
- data/app/views/surveyor_gui/question_groups/_group_inline_fields.html.erb +25 -0
- data/app/views/surveyor_gui/question_groups/blank.html.erb +0 -0
- data/app/views/surveyor_gui/question_groups/edit.html.erb +1 -0
- data/app/views/surveyor_gui/question_groups/new.html.erb +1 -0
- data/app/views/surveyor_gui/questions/_answer_fields.html.erb +23 -0
- data/app/views/surveyor_gui/questions/_answer_options.html.erb +28 -0
- data/app/views/surveyor_gui/questions/_form.html.erb +66 -0
- data/app/views/surveyor_gui/questions/_grid_dropdown_columns.html.erb +10 -0
- data/app/views/surveyor_gui/questions/_grid_dropdown_fields.html.erb +42 -0
- data/app/views/surveyor_gui/questions/_grid_fields.html.erb +9 -0
- data/app/views/surveyor_gui/questions/_no_picks.html.erb +29 -0
- data/app/views/surveyor_gui/questions/_pick.html +21 -0
- data/app/views/surveyor_gui/questions/_picks.html.erb +12 -0
- data/app/views/surveyor_gui/questions/blank.html.erb +0 -0
- data/app/views/surveyor_gui/questions/edit.html.erb +1 -0
- data/app/views/surveyor_gui/questions/new.html.erb +1 -0
- data/app/views/surveyor_gui/reports/_graphs.html.haml +21 -0
- data/app/views/surveyor_gui/reports/_grid.html.haml +42 -0
- data/app/views/surveyor_gui/reports/_grid_dropdown.html.haml +56 -0
- data/app/views/surveyor_gui/reports/_repeater.html.haml +27 -0
- data/app/views/surveyor_gui/reports/_show_report.html.haml +33 -0
- data/app/views/surveyor_gui/reports/_single_question.html.haml +70 -0
- data/app/views/surveyor_gui/reports/show.html.erb +14 -0
- data/app/views/surveyor_gui/responses/_grid.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_grid_dropdown.html.haml +20 -0
- data/app/views/surveyor_gui/responses/_repeater.html.haml +22 -0
- data/app/views/surveyor_gui/responses/_survey_results.html.haml +40 -0
- data/app/views/surveyor_gui/responses/index.html.haml +24 -0
- data/app/views/surveyor_gui/responses/show.html.haml +42 -0
- data/app/views/surveyor_gui/shared/_grid_comments.html.haml +10 -0
- data/app/views/surveyor_gui/shared/_new_line.html.haml +2 -0
- data/app/views/surveyor_gui/shared/_pick_comments.html.haml +15 -0
- data/app/views/surveyor_gui/shared/_question_number.html.haml +11 -0
- data/app/views/surveyor_gui/shared/_report_data.html.haml +27 -0
- data/app/views/surveyor_gui/shared/_stars_report_data.html.haml +14 -0
- data/app/views/surveyor_gui/survey_sections/_form.html.erb +13 -0
- data/app/views/surveyor_gui/survey_sections/blank.html.erb +0 -0
- data/app/views/surveyor_gui/survey_sections/edit.html.erb +1 -0
- data/app/views/surveyor_gui/survey_sections/new.html.erb +1 -0
- data/app/views/surveyor_gui/surveyforms/_form.html.erb +50 -0
- data/app/views/surveyor_gui/surveyforms/_question_field.html.erb +148 -0
- data/app/views/surveyor_gui/surveyforms/_question_group.html.erb +116 -0
- data/app/views/surveyor_gui/surveyforms/_question_group_fields.html.erb +3 -0
- data/app/views/surveyor_gui/surveyforms/_question_name_and_number.html.erb +6 -0
- data/app/views/surveyor_gui/surveyforms/_question_section.html.erb +15 -0
- data/app/views/surveyor_gui/surveyforms/_question_wrapper.html.erb +108 -0
- data/app/views/surveyor_gui/surveyforms/_survey_section_fields.html.erb +137 -0
- data/app/views/surveyor_gui/surveyforms/clone_survey.html.erb +13 -0
- data/app/views/surveyor_gui/surveyforms/edit.html.erb +5 -0
- data/app/views/surveyor_gui/surveyforms/index.html.erb +40 -0
- data/app/views/surveyor_gui/surveyforms/new.html.erb +1 -0
- data/app/views/surveyor_gui/surveyforms/show.html.erb +5 -0
- data/config/environment.rb +0 -0
- data/config/routes.rb +71 -0
- data/config.ru +4 -0
- data/db/migrate/20140307204049_add_template_to_surveys.rb +5 -0
- data/db/migrate/20140307235607_add_test_data_to_response_sets.rb +5 -0
- data/db/migrate/20140308171947_add_original_choice_to_answers.rb +5 -0
- data/db/migrate/20140308172118_add_blob_to_responses.rb +5 -0
- data/db/migrate/20140308172417_add_modifiable_to_survey_section.rb +5 -0
- data/db/migrate/20140308174532_add_modifiable_to_question.rb +5 -0
- data/db/migrate/20140308175305_add_dynamically_generate_to_questions.rb +5 -0
- data/db/migrate/20140311032923_add_dummy_blob_to_questions.rb +5 -0
- data/db/migrate/20140311160609_add_dynamic_source_to_questions.rb +5 -0
- data/db/migrate/20140311161714_add_report_code_to_questions.rb +5 -0
- data/db/migrate/20140530181134_add_is_comment_to_questions.rb +5 -0
- data/db/migrate/20140531012006_add_is_comment_to_answers.rb +5 -0
- data/db/migrate/20140531225529_create_rows.rb +9 -0
- data/db/migrate/20140601011151_create_columns.rb +11 -0
- data/db/migrate/20140602030330_add_column_id_to_answers.rb +5 -0
- data/db/migrate/20140603155606_add_column_id_to_responses.rb +5 -0
- data/db/migrate/20140606023527_add_column_id_to_dependency_conditions.rb +5 -0
- data/db/migrate/20140815165307_add_user_id_to_survey.rb +5 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/assets/images/addicon.png +0 -0
- data/lib/assets/images/datepicker.gif +0 -0
- data/lib/assets/images/delete.gif +0 -0
- data/lib/assets/images/delete.png +0 -0
- data/lib/assets/images/images/border.png +0 -0
- data/lib/assets/images/images/controls.png +0 -0
- data/lib/assets/images/images/loading.gif +0 -0
- data/lib/assets/images/images/loading_background.png +0 -0
- data/lib/assets/images/images/overlay.png +0 -0
- data/lib/assets/images/rails.png +0 -0
- data/lib/assets/images/star.gif +0 -0
- data/lib/assets/javascripts/.gitkeep +0 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.MetaData.js +121 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.blockUI.js +619 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.rating.js +377 -0
- data/lib/assets/javascripts/surveyor_gui/jquery.validate.js +1188 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_add_ons.js +10 -0
- data/lib/assets/javascripts/surveyor_gui/surveyor_gui.js +1428 -0
- data/lib/assets/stylesheets/.gitkeep +0 -0
- data/lib/assets/stylesheets/surveyor_gui/jquery.rating.css +12 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_add_ons.css +3 -0
- data/lib/assets/stylesheets/surveyor_gui/surveyor_gui.sass +652 -0
- data/lib/enumerable_extenders.rb +31 -0
- data/lib/generators/surveyor_gui/install_generator.rb +57 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_add_ons.js +2 -0
- data/lib/generators/surveyor_gui/templates/app/assets/javascripts/surveyor_gui_all.js +24 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_add_ons.css.sass +1 -0
- data/lib/generators/surveyor_gui/templates/app/assets/stylesheets/surveyor_gui_all.css.sass +8 -0
- data/lib/generators/surveyor_gui/templates/app/helpers/surveyor_helper.rb +4 -0
- data/lib/generators/surveyor_gui/templates/app/models/response_set_user.rb +13 -0
- data/lib/generators/surveyor_gui/templates/app/views/layouts/surveyor_gui/surveyor_gui_default.html.erb +17 -0
- data/lib/generators/surveyor_gui/templates/config/initializers/simple_form.rb +140 -0
- data/lib/generators/surveyor_gui/templates/config/locales/en.yml +5 -0
- data/lib/surveyor_gui/engine.rb +31 -0
- data/lib/surveyor_gui/helpers/surveyor_helper_methods.rb +19 -0
- data/lib/surveyor_gui/models/answer_methods.rb +24 -0
- data/lib/surveyor_gui/models/column_methods.rb +43 -0
- data/lib/surveyor_gui/models/dependency_condition_methods.rb +53 -0
- data/lib/surveyor_gui/models/dependency_methods.rb +83 -0
- data/lib/surveyor_gui/models/question_and_group_shared_methods.rb +11 -0
- data/lib/surveyor_gui/models/question_group_methods.rb +55 -0
- data/lib/surveyor_gui/models/question_methods.rb +435 -0
- data/lib/surveyor_gui/models/question_type_methods.rb +493 -0
- data/lib/surveyor_gui/models/response_methods.rb +71 -0
- data/lib/surveyor_gui/models/response_set_methods.rb +56 -0
- data/lib/surveyor_gui/models/row_methods.rb +11 -0
- data/lib/surveyor_gui/models/survey_methods.rb +32 -0
- data/lib/surveyor_gui/models/survey_section_methods.rb +32 -0
- data/lib/surveyor_gui/surveyforms_controller_methods.rb +258 -0
- data/lib/surveyor_gui/version.rb +3 -0
- data/lib/surveyor_gui.rb +17 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/surveyor_gui_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/controllers/surveyforms_controller_spec.rb +362 -0
- data/spec/controllers/surveyor_controller_spec.rb +303 -0
- data/spec/factories.rb +181 -0
- data/spec/features/create_survey_spec.rb +417 -0
- data/spec/features/dependencies_spec.rb +65 -0
- data/spec/features/make_and_take_spec.rb +187 -0
- data/spec/features/rearrange_survey_spec.rb +118 -0
- data/spec/features/ui_spec.rb +469 -0
- data/spec/fixtures/REDCapDemoDatabase_DataDictionary.csv +127 -0
- data/spec/fixtures/chinese_survey.rb +14 -0
- data/spec/fixtures/everything.rb +215 -0
- data/spec/fixtures/favorites-ish.rb +22 -0
- data/spec/fixtures/favorites.rb +22 -0
- data/spec/fixtures/feelings.rb +38 -0
- data/spec/fixtures/lifestyle.rb +55 -0
- data/spec/fixtures/numbers.rb +21 -0
- data/spec/fixtures/redcap_new_headers.csv +1 -0
- data/spec/fixtures/redcap_siblings.csv +1 -0
- data/spec/fixtures/redcap_whitespace.csv +1 -0
- data/spec/helpers/formtastic_custom_input_spec.rb +15 -0
- data/spec/helpers/surveyor_helper_spec.rb +116 -0
- data/spec/lib/common_spec.rb +37 -0
- data/spec/lib/parser_spec.rb +393 -0
- data/spec/lib/rake_kitchen_sink.rb +42 -0
- data/spec/lib/redcap_parser_spec.rb +129 -0
- data/spec/lib/unparser_spec.rb +126 -0
- data/spec/models/answer_spec.rb +144 -0
- data/spec/models/dependency_condition_spec.rb +428 -0
- data/spec/models/dependency_spec.rb +90 -0
- data/spec/models/question_group_spec.rb +66 -0
- data/spec/models/question_spec.rb +176 -0
- data/spec/models/response_set_spec.rb +452 -0
- data/spec/models/response_spec.rb +208 -0
- data/spec/models/survey_section_spec.rb +58 -0
- data/spec/models/survey_spec.rb +155 -0
- data/spec/models/surveyor_gui/question_spec.rb +60 -0
- data/spec/models/surveyor_gui/question_type_spec.rb +268 -0
- data/spec/models/validation_condition_spec.rb +98 -0
- data/spec/models/validation_spec.rb +64 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +119 -0
- data/spec/support/scenario_outline_helper.rb +39 -0
- data/spec/support/shared.rb +10 -0
- data/spec/support/surveyforms_creation_helpers.rb +313 -0
- data/spec/support/surveyforms_rearrangement_helpers.rb +170 -0
- data/spec/support/surveyor_api_helpers.rb +15 -0
- data/spec/support/surveyor_ui_helpers.rb +108 -0
- data/spec/support/wait_for_ajax.rb +11 -0
- data/spec/views/questions/edit.html.erb_spec.rb +74 -0
- data/spec/views/surveyforms/edit.html.erb_spec.rb +126 -0
- data/surveyor_gui.gemspec +52 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/surveyor-gui_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
- data/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/custom.sass +5 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +600 -0
@@ -0,0 +1,15 @@
|
|
1
|
+
module SurveyorAPIHelpers
|
2
|
+
def json_response
|
3
|
+
page.source
|
4
|
+
end
|
5
|
+
def title_modification_module(modifier)
|
6
|
+
mod = Module.new
|
7
|
+
mod.send(:define_method, :filtered_for_json) do
|
8
|
+
dolly = self.clone
|
9
|
+
dolly.sections = self.sections
|
10
|
+
dolly.title = "#{modifier} #{dolly.title}"
|
11
|
+
dolly
|
12
|
+
end
|
13
|
+
return mod
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# http://www.elabs.se/blog/51-simple-tricks-to-clean-up-your-capybara-tests
|
2
|
+
require 'mustache'
|
3
|
+
module SurveyorUIHelpers
|
4
|
+
def have_disabled_selected_radio(text)
|
5
|
+
within("label", :text => text) do
|
6
|
+
have_selector('input[type=radio][disabled=disabled]')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
def have_disabled_selected_checkbox(text)
|
10
|
+
within("label", :text => text) do
|
11
|
+
have_selector('input[type=checkbox][disabled=disabled]')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def grid_row(text)
|
15
|
+
find("fieldset.g_grid tr#q_#{Question.where(text: text).first.id}")
|
16
|
+
end
|
17
|
+
def question(reference_identifier, entry = nil)
|
18
|
+
if entry
|
19
|
+
find("fieldset#q_#{Question.where(reference_identifier: reference_identifier).first.id}_#{entry}")
|
20
|
+
else
|
21
|
+
find("fieldset#q_#{Question.where(reference_identifier: reference_identifier).first.id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def have_hidden_question(reference_identifier, entry=nil)
|
25
|
+
if entry
|
26
|
+
have_css("fieldset#q_#{Question.where(reference_identifier: reference_identifier).first.id}_#{entry}.q_hidden")
|
27
|
+
else
|
28
|
+
have_css("fieldset#q_#{Question.where(reference_identifier: reference_identifier).first.id}.q_hidden")
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
def have_hidden_group(reference_identifier, entry = nil)
|
33
|
+
if entry
|
34
|
+
have_css("fieldset#g_#{QuestionGroup.where(reference_identifier: reference_identifier).first.id}_#{entry}.g_hidden")
|
35
|
+
else
|
36
|
+
have_css("fieldset#g_#{QuestionGroup.where(reference_identifier: reference_identifier).first.id}.g_hidden")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
def group(reference_identifier)
|
40
|
+
find("fieldset#g_#{QuestionGroup.where(reference_identifier: reference_identifier).first.id}")
|
41
|
+
end
|
42
|
+
def checkbox(q_ref_id, a_ref_id)
|
43
|
+
find("input[value='#{Question.where(reference_identifier: q_ref_id).first.answers.where(reference_identifier: a_ref_id).first.id}']")
|
44
|
+
end
|
45
|
+
def start_survey(name, opts = {})
|
46
|
+
visit(opts[:locale] ? "/surveys?locale=#{opts[:locale]}" : '/surveys')
|
47
|
+
within "form", text: name do
|
48
|
+
select(opts[:version], from: "version") if opts[:version]
|
49
|
+
click_button I18n.t('surveyor.take_it')
|
50
|
+
end
|
51
|
+
return ResponseSet.where(access_code: current_path.split('/')[3]).first.extend ResponseSetTestingMethods
|
52
|
+
end
|
53
|
+
def the_15th
|
54
|
+
Date.current.beginning_of_month + 14
|
55
|
+
end
|
56
|
+
|
57
|
+
def hash_context_module(hash)
|
58
|
+
mod = Module.new
|
59
|
+
mod.send(:define_method, :render_context) do
|
60
|
+
return hash
|
61
|
+
end
|
62
|
+
return mod
|
63
|
+
end
|
64
|
+
def mustache_context_module(hash)
|
65
|
+
context = Class.new(::Mustache)
|
66
|
+
hash.each do |k,v|
|
67
|
+
context.send(:define_method, k.to_sym) do
|
68
|
+
v
|
69
|
+
end
|
70
|
+
end
|
71
|
+
mod = Module.new
|
72
|
+
mod.send(:define_method, :render_context) do
|
73
|
+
context
|
74
|
+
end
|
75
|
+
return mod
|
76
|
+
end
|
77
|
+
def override_surveyor_helper_numbering
|
78
|
+
SurveyorHelper.module_eval do
|
79
|
+
def next_question_number(question)
|
80
|
+
@letters ||= ("A".."Z").to_a
|
81
|
+
@n ||= 25
|
82
|
+
"<span class='qnum'>#{@letters[(@n += 1)%26]}. </span>"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
def restore_surveyor_helper_numbering
|
87
|
+
SurveyorHelper.module_eval do
|
88
|
+
def next_question_number(question)
|
89
|
+
@n ||= 0
|
90
|
+
"<span class='qnum'>#{@n += 1}) </span>"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
module ResponseSetTestingMethods
|
96
|
+
def for(q_ref_id, a_ref_id = nil)
|
97
|
+
q = Question.where(reference_identifier: q_ref_id).first
|
98
|
+
if a_ref_id
|
99
|
+
a = Answer.where(reference_identifier: a_ref_id, question_id: q.id).first
|
100
|
+
responses.where(question_id: q.id, answer_id: a.id)
|
101
|
+
else
|
102
|
+
responses.where(question_id: q.id)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
def count
|
106
|
+
responses.count
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CapybaraHelper
|
4
|
+
Capybara::Session::DSL_METHODS.each do |method|
|
5
|
+
define_method method do |*args, &block|
|
6
|
+
Capybara.string(response).send method, *args, &block
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "surveyor_gui/questions/edit.html.erb" do
|
12
|
+
include CapybaraHelper
|
13
|
+
|
14
|
+
let(:question){ FactoryGirl.create(:question) }
|
15
|
+
let(:question2){ FactoryGirl.create(:question, :question_type_id => "pick_one") }
|
16
|
+
let(:form){find('form')}
|
17
|
+
|
18
|
+
before do
|
19
|
+
@routes = SurveyorGui::Engine.routes
|
20
|
+
assign(:question, question)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "renders a form" do
|
24
|
+
render
|
25
|
+
expect(response).to have_selector("form")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "will post a new question on submit" do
|
29
|
+
render
|
30
|
+
expect(form[:action]).to eql(surveyor_gui.question_path question)
|
31
|
+
expect(form[:method]).to eql('post')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "has a save button" do
|
35
|
+
render
|
36
|
+
expect(form).to have_selector("input[type=submit]")
|
37
|
+
end
|
38
|
+
|
39
|
+
context "It has a multiple choice field" do
|
40
|
+
let (:form) {find('form')}
|
41
|
+
let(:answer_1){ FactoryGirl.create(:answer, :question => question2, :display_order => 3, :text => "blue")}
|
42
|
+
let(:answer_2){ FactoryGirl.create(:answer, :question => question2, :display_order => 1, :text => "red")}
|
43
|
+
let(:answer_3){ FactoryGirl.create(:answer, :question => question2, :display_order => 2, :text => "green")}
|
44
|
+
|
45
|
+
before do
|
46
|
+
[answer_1, answer_2, answer_3].each{|a| question2.answers << a }
|
47
|
+
assign(:question, question2)
|
48
|
+
end
|
49
|
+
|
50
|
+
#won't work for now because of js
|
51
|
+
#it "renders an answer_collection for the answers" do
|
52
|
+
# render
|
53
|
+
# puts rendered
|
54
|
+
# expect(rendered).to have_field(
|
55
|
+
# 'question[answers_textbox]',
|
56
|
+
# :type => 'textarea',
|
57
|
+
# :with => "red\ngreen\nblue")
|
58
|
+
#end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
# it "renders a text field for the message title" do
|
63
|
+
# render
|
64
|
+
# expect(form).to have_field(
|
65
|
+
# "message[title]",
|
66
|
+
# :type => 'text',
|
67
|
+
# :with => 'the title')
|
68
|
+
# end
|
69
|
+
# it "renders a text area for the message text" do
|
70
|
+
# render
|
71
|
+
|
72
|
+
# end
|
73
|
+
# end
|
74
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CapybaraHelper
|
4
|
+
Capybara::Session::DSL_METHODS.each do |method|
|
5
|
+
define_method method do |*args, &block|
|
6
|
+
Capybara.string(response).send method, *args, &block
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.order = :default
|
12
|
+
end
|
13
|
+
describe "surveyor_gui/surveyforms/edit.html.erb" do
|
14
|
+
include CapybaraHelper
|
15
|
+
let(:surveyform){ FactoryGirl.create(:surveyform) }
|
16
|
+
let(:ss){ FactoryGirl.create(:survey_section, :surveyform => surveyform, :title => "Rooms", :display_order => 0)}
|
17
|
+
let(:question){ FactoryGirl.create(:question, :survey_section => ss, display_order: 0 )}
|
18
|
+
let(:answer){ FactoryGirl.create(:answer, :question => question)}
|
19
|
+
let(:question1){ FactoryGirl.create(
|
20
|
+
:question,
|
21
|
+
survey_section: ss,
|
22
|
+
text: 'What rooms do you prefer?',
|
23
|
+
question_type_id: "pick_one",
|
24
|
+
answers_textbox: "Standard\nDouble\nDeluxe",
|
25
|
+
display_order: 1
|
26
|
+
) }
|
27
|
+
|
28
|
+
let(:qg) {FactoryGirl.create(:question_group, display_type: 'grid', text: 'Rate the meals.') }
|
29
|
+
let(:qg2){FactoryGirl.create(:question_group, display_type: 'grid', text: 'Pick your favorite sport') }
|
30
|
+
let(:c1) {FactoryGirl.create(:column, question_group_id: qg2.id, text: "Spring", answers_textbox: "Football\nBaseball\nHockey\nSoccer\nBasketball" )}
|
31
|
+
let(:c2) {FactoryGirl.create(:column, question_group_id: qg2.id, text: "Summer", answers_textbox: "Football\nBaseball\nHockey\nSoccer\nBasketball" )}
|
32
|
+
let(:c3) {FactoryGirl.create(:column, question_group_id: qg2.id, text: "Fall", answers_textbox: "Football\nBaseball\nHockey\nSoccer\nBasketball")}
|
33
|
+
let(:c4) {FactoryGirl.create(:column, question_group_id: qg2.id, text: "Winter", answers_textbox: "Football\nBaseball\nHockey\nSoccer\nBasketball")}
|
34
|
+
let(:question2){ FactoryGirl.create(
|
35
|
+
:question,
|
36
|
+
text: 'Rate the meals.',
|
37
|
+
survey_section: ss,
|
38
|
+
question_group: nil,
|
39
|
+
question_type_id: "grid_one",
|
40
|
+
grid_columns_textbox: "Good\nBad\nUgly",
|
41
|
+
grid_rows_textbox: "Breakfast\nLunch\nDinner",
|
42
|
+
display_order: 4
|
43
|
+
) }
|
44
|
+
|
45
|
+
let(:question5){ FactoryGirl.create(:question, :survey_section => ss, text: "What brand of ketchup do they use?", display_order: 7 )}
|
46
|
+
let(:answer1){FactoryGirl.create(:answer, :question => question5)}
|
47
|
+
let(:question6) { FactoryGirl.create(
|
48
|
+
:question,
|
49
|
+
survey_section: ss,
|
50
|
+
question_group: qg2,
|
51
|
+
question_type_id: "grid_dropdown",
|
52
|
+
grid_rows_textbox: "TV\nArena",
|
53
|
+
text: "Pick your favorite sport:",
|
54
|
+
display_order: 8
|
55
|
+
) }
|
56
|
+
let(:number_question) {FactoryGirl.create(
|
57
|
+
:question,
|
58
|
+
survey_section: ss,
|
59
|
+
text: "How much do you spend on Cheese Doodles?",
|
60
|
+
question_type_id: "number",
|
61
|
+
suffix: "$",
|
62
|
+
prefix: "USD",
|
63
|
+
display_order: 10
|
64
|
+
) }
|
65
|
+
|
66
|
+
before do
|
67
|
+
surveyform.save
|
68
|
+
surveyform.reload
|
69
|
+
ss.reload
|
70
|
+
qg.reload
|
71
|
+
qg2.reload
|
72
|
+
answer.reload
|
73
|
+
question.reload
|
74
|
+
question1.reload
|
75
|
+
question2.reload
|
76
|
+
question5.reload
|
77
|
+
answer1.reload
|
78
|
+
c1.reload
|
79
|
+
c2.reload
|
80
|
+
c3.reload
|
81
|
+
c4.reload
|
82
|
+
question6.reload
|
83
|
+
number_question.reload
|
84
|
+
assign(:surveyform, surveyform)
|
85
|
+
assign(:question_no, 0)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "renders a form" do
|
89
|
+
render
|
90
|
+
expect(response).to have_selector("form")
|
91
|
+
end
|
92
|
+
|
93
|
+
it "shows text questions" do
|
94
|
+
render
|
95
|
+
expect(response).to match(/1\) What is your favorite color?/)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "shows multiple choice questions" do
|
99
|
+
render
|
100
|
+
expect(response).to have_selector("input[type='radio'][value='Standard']")
|
101
|
+
expect(response).to have_selector("input[type='radio'][value='Double']")
|
102
|
+
expect(response).to have_selector("input[type='radio'][value='Deluxe']")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "shows grid questions" do
|
106
|
+
render
|
107
|
+
expect(response).to match (/Rate the meals/)
|
108
|
+
expect(response).to match(/3\) Rate the meals\..*Good.*Bad.*Ugly.*(?<!\d\)\s)Breakfast.*(?<!\d\)\s)Lunch.*(?<!\d\)\s)Dinner.*/m)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "shows grid dropdowns" do
|
112
|
+
render
|
113
|
+
expect(response).to match(/5\) Pick your favorite sport.*Spring.*Summer.*Fall.*Winter.*(?<!\d\)\s)TV.*(?<!\d\)\s)Arena/m)
|
114
|
+
end
|
115
|
+
|
116
|
+
it "maintains correct question numbering after grid questions" do
|
117
|
+
render
|
118
|
+
expect(response).to match(/4\) What brand of ketchup do they use?/)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "shows a prefix and suffix for number questions" do
|
122
|
+
render
|
123
|
+
expect(response).to match(/How much do you spend on Cheese Doodles?/)
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "surveyor_gui/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "upgrade_surveyor_gui"
|
9
|
+
s.version = SurveyorGui::VERSION
|
10
|
+
s.authors = ["Prateek Singh","Sandeep Singh"]
|
11
|
+
s.email = ["prateekbundela87@gmail.com"]
|
12
|
+
s.homepage = %q{https://github.com/prateeksinghbundela/surveyor_gui.git}
|
13
|
+
s.post_install_message = %q{Thanks for installing surveyor_gui! The time has come to run the surveyor_gui generator and migrate your database, even if you are upgrading.}
|
14
|
+
s.summary = "A Rails gem to supply a front-end and reporting capability to the Surveyor gem."
|
15
|
+
|
16
|
+
#s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n") - ['irb']
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
|
23
|
+
s.add_dependency 'rails', '~> 6.1.3'
|
24
|
+
# s.add_dependency 'dynamic_form', '~> 1.1.4'
|
25
|
+
#s.add_dependency 'jquery-ui-rails'
|
26
|
+
s.add_dependency 'jquery-ui-sass-rails'
|
27
|
+
|
28
|
+
s.add_development_dependency "sqlite3"
|
29
|
+
|
30
|
+
s.add_development_dependency 'sass-rails','< 5.1'
|
31
|
+
s.add_development_dependency 'coffee-rails'
|
32
|
+
s.add_development_dependency 'uglifier', '>= 1.0.3'
|
33
|
+
s.add_development_dependency('rspec-rails', '~> 2.14.2')
|
34
|
+
s.add_development_dependency('capybara', '~> 3.33')
|
35
|
+
s.add_development_dependency('launchy', '~> 2.4.2')
|
36
|
+
s.add_development_dependency('poltergeist', '~>1.18')
|
37
|
+
# s.add_development_dependency('capybara-webkit','~> 1.15', '>= 1.15.1' )
|
38
|
+
s.add_development_dependency('json_spec', '~> 1.1.1')
|
39
|
+
s.add_development_dependency('factory_girl', '~> 4.4.0')
|
40
|
+
s.add_development_dependency('database_cleaner', '~> 1.2.0')
|
41
|
+
s.add_development_dependency('rspec-retry')
|
42
|
+
|
43
|
+
# s.add_dependency 'surveyor', '~> 1.4.1.pre'
|
44
|
+
s.add_dependency 'will_paginate', '~> 3.3.0'
|
45
|
+
|
46
|
+
# s.add_dependency 'simple_form', '~> 5.0.2'
|
47
|
+
# s.add_dependency 'carrierwave'
|
48
|
+
s.add_dependency 'colorbox-rails'
|
49
|
+
s.add_dependency 'jquery-form-rails'
|
50
|
+
s.add_dependency 'deep_cloneable'
|
51
|
+
s.add_dependency 'lazy_high_charts'
|
52
|
+
end
|
@@ -0,0 +1,261 @@
|
|
1
|
+
== Welcome to Rails
|
2
|
+
|
3
|
+
Rails is a web-application framework that includes everything needed to create
|
4
|
+
database-backed web applications according to the Model-View-Control pattern.
|
5
|
+
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
13
|
+
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
17
|
+
methods. You can read more about Active Record in
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
19
|
+
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
25
|
+
Rails. You can read more about Action Pack in
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
27
|
+
|
28
|
+
|
29
|
+
== Getting Started
|
30
|
+
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
+
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
+
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
+
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
42
|
+
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
+
|
46
|
+
|
47
|
+
== Debugging Rails
|
48
|
+
|
49
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
+
will help you debug it and get it back on the rails.
|
51
|
+
|
52
|
+
First area to check is the application log files. Have "tail -f" commands
|
53
|
+
running on the server.log and development.log. Rails will automatically display
|
54
|
+
debugging and runtime information to these files. Debugging info will also be
|
55
|
+
shown in the browser on requests from 127.0.0.1.
|
56
|
+
|
57
|
+
You can also log your own messages directly into the log file from your code
|
58
|
+
using the Ruby logger class from inside your controllers. Example:
|
59
|
+
|
60
|
+
class WeblogController < ActionController::Base
|
61
|
+
def destroy
|
62
|
+
@weblog = Weblog.find(params[:id])
|
63
|
+
@weblog.destroy
|
64
|
+
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
The result will be a message in your log file along the lines of:
|
69
|
+
|
70
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
+
|
72
|
+
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
+
|
74
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
+
several books available online as well:
|
76
|
+
|
77
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
+
|
80
|
+
These two books will bring you up to speed on the Ruby language and also on
|
81
|
+
programming in general.
|
82
|
+
|
83
|
+
|
84
|
+
== Debugger
|
85
|
+
|
86
|
+
Debugger support is available through the debugger command when you start your
|
87
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
+
execution at any point in the code, investigate and change the model, and then,
|
89
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
+
|
92
|
+
class WeblogController < ActionController::Base
|
93
|
+
def index
|
94
|
+
@posts = Post.all
|
95
|
+
debugger
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
So the controller will accept the action, run the first line, then present you
|
100
|
+
with a IRB prompt in the server window. Here you can do things like:
|
101
|
+
|
102
|
+
>> @posts.inspect
|
103
|
+
=> "[#<Post:0x14a6be8
|
104
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
+
#<Post:0x14a6620
|
106
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
+
>> @posts.first.title = "hello from a debugger"
|
108
|
+
=> "hello from a debugger"
|
109
|
+
|
110
|
+
...and even better, you can examine how your runtime objects actually work:
|
111
|
+
|
112
|
+
>> f = @posts.first
|
113
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
+
>> f.
|
115
|
+
Display all 152 possibilities? (y or n)
|
116
|
+
|
117
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
+
|
119
|
+
|
120
|
+
== Console
|
121
|
+
|
122
|
+
The console is a Ruby shell, which allows you to interact with your
|
123
|
+
application's domain model. Here you'll have all parts of the application
|
124
|
+
configured, just like it is when the application is running. You can inspect
|
125
|
+
domain models, change values, and save to the database. Starting the script
|
126
|
+
without arguments will launch it in the development environment.
|
127
|
+
|
128
|
+
To start the console, run <tt>rails console</tt> from the application
|
129
|
+
directory.
|
130
|
+
|
131
|
+
Options:
|
132
|
+
|
133
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
+
made to the database.
|
135
|
+
* Passing an environment name as an argument will load the corresponding
|
136
|
+
environment. Example: <tt>rails console production</tt>.
|
137
|
+
|
138
|
+
To reload your controllers and models after launching the console run
|
139
|
+
<tt>reload!</tt>
|
140
|
+
|
141
|
+
More information about irb can be found at:
|
142
|
+
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
+
|
144
|
+
|
145
|
+
== dbconsole
|
146
|
+
|
147
|
+
You can go to the command line of your database directly through <tt>rails
|
148
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
+
defined in database.yml. Starting the script without arguments will connect you
|
150
|
+
to the development database. Passing an argument will connect you to a different
|
151
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
+
PostgreSQL and SQLite 3.
|
153
|
+
|
154
|
+
== Description of Contents
|
155
|
+
|
156
|
+
The default directory structure of a generated Ruby on Rails application:
|
157
|
+
|
158
|
+
|-- app
|
159
|
+
| |-- assets
|
160
|
+
| | |-- images
|
161
|
+
| | |-- javascripts
|
162
|
+
| | `-- stylesheets
|
163
|
+
| |-- controllers
|
164
|
+
| |-- helpers
|
165
|
+
| |-- mailers
|
166
|
+
| |-- models
|
167
|
+
| `-- views
|
168
|
+
| `-- layouts
|
169
|
+
|-- config
|
170
|
+
| |-- environments
|
171
|
+
| |-- initializers
|
172
|
+
| `-- locales
|
173
|
+
|-- db
|
174
|
+
|-- doc
|
175
|
+
|-- lib
|
176
|
+
| |-- assets
|
177
|
+
| `-- tasks
|
178
|
+
|-- log
|
179
|
+
|-- public
|
180
|
+
|-- script
|
181
|
+
|-- test
|
182
|
+
| |-- fixtures
|
183
|
+
| |-- functional
|
184
|
+
| |-- integration
|
185
|
+
| |-- performance
|
186
|
+
| `-- unit
|
187
|
+
|-- tmp
|
188
|
+
| `-- cache
|
189
|
+
| `-- assets
|
190
|
+
`-- vendor
|
191
|
+
|-- assets
|
192
|
+
| |-- javascripts
|
193
|
+
| `-- stylesheets
|
194
|
+
`-- plugins
|
195
|
+
|
196
|
+
app
|
197
|
+
Holds all the code that's specific to this particular application.
|
198
|
+
|
199
|
+
app/assets
|
200
|
+
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
+
|
202
|
+
app/controllers
|
203
|
+
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
+
automated URL mapping. All controllers should descend from
|
205
|
+
ApplicationController which itself descends from ActionController::Base.
|
206
|
+
|
207
|
+
app/models
|
208
|
+
Holds models that should be named like post.rb. Models descend from
|
209
|
+
ActiveRecord::Base by default.
|
210
|
+
|
211
|
+
app/views
|
212
|
+
Holds the template files for the view that should be named like
|
213
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
+
eRuby syntax by default.
|
215
|
+
|
216
|
+
app/views/layouts
|
217
|
+
Holds the template files for layouts to be used with views. This models the
|
218
|
+
common header/footer method of wrapping views. In your views, define a layout
|
219
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
+
layout.
|
222
|
+
|
223
|
+
app/helpers
|
224
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
+
generated for you automatically when using generators for controllers.
|
226
|
+
Helpers can be used to wrap functionality for your views into methods.
|
227
|
+
|
228
|
+
config
|
229
|
+
Configuration files for the Rails environment, the routing map, the database,
|
230
|
+
and other dependencies.
|
231
|
+
|
232
|
+
db
|
233
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
+
sequence of Migrations for your schema.
|
235
|
+
|
236
|
+
doc
|
237
|
+
This directory is where your application documentation will be stored when
|
238
|
+
generated using <tt>rake doc:app</tt>
|
239
|
+
|
240
|
+
lib
|
241
|
+
Application specific libraries. Basically, any kind of custom code that
|
242
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
+
the load path.
|
244
|
+
|
245
|
+
public
|
246
|
+
The directory available for the web server. Also contains the dispatchers and the
|
247
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
+
server.
|
249
|
+
|
250
|
+
script
|
251
|
+
Helper scripts for automation and generation.
|
252
|
+
|
253
|
+
test
|
254
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
+
command, template test files will be generated for you and placed in this
|
256
|
+
directory.
|
257
|
+
|
258
|
+
vendor
|
259
|
+
External libraries that the application depends on. Also includes the plugins
|
260
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
+
vendor/rails/. This directory is in the load path.
|