surveyor 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +4 -1
- data/app/views/partials/_answer.html.haml +1 -1
- data/app/views/partials/_section_menu.html.haml +8 -1
- data/app/views/surveyor/edit.html.haml +1 -1
- data/app/views/surveyor/new.html.haml +1 -1
- data/app/views/surveyor/show.html.haml +17 -20
- data/ci-exec.sh +1 -1
- data/config/routes.rb +7 -7
- data/features/internationalization.feature +68 -2
- data/features/show_survey.feature +29 -0
- data/features/step_definitions/parser_steps.rb +15 -0
- data/features/step_definitions/surveyor_steps.rb +11 -9
- data/features/support/paths.rb +5 -2
- data/features/z_redcap_parser.feature +4 -1
- data/lib/assets/javascripts/surveyor/jquery.surveyor.js +5 -1
- data/lib/assets/stylesheets/surveyor.sass +2 -0
- data/lib/generators/surveyor/install_generator.rb +4 -0
- data/lib/generators/surveyor/templates/app/controllers/surveyor_controller.rb +2 -2
- data/lib/generators/surveyor/templates/config/locales/surveyor_en.yml +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/config/locales/surveyor_ko.yml +2 -1
- data/lib/generators/surveyor/templates/surveys/languages.rb +9 -5
- data/lib/generators/surveyor/templates/surveys/translations/languages.es.yml +4 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.he.yml +4 -0
- data/lib/generators/surveyor/templates/surveys/translations/languages.ko.yml +4 -0
- data/lib/surveyor/helpers/surveyor_helper_methods.rb +1 -1
- data/lib/surveyor/models/answer_methods.rb +2 -2
- data/lib/surveyor/models/question_methods.rb +3 -3
- data/lib/surveyor/models/response_methods.rb +18 -5
- data/lib/surveyor/models/response_set_methods.rb +1 -1
- data/lib/surveyor/models/survey_methods.rb +2 -2
- data/lib/surveyor/models/survey_section_methods.rb +2 -2
- data/lib/surveyor/parser.rb +25 -4
- data/lib/surveyor/redcap_parser.rb +13 -13
- data/lib/surveyor/surveyor_controller_methods.rb +22 -19
- data/lib/surveyor/version.rb +1 -1
- data/lib/tasks/surveyor_tasks.rake +1 -1
- data/spec/controllers/surveyor_controller_spec.rb +155 -269
- data/spec/lib/parser_spec.rb +189 -21
- data/spec/models/response_set_spec.rb +7 -5
- data/spec/spec_helper.rb +3 -1
- data/stacktests.sh +1 -1
- data/surveyor.gemspec +3 -1
- metadata +271 -275
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
History for Surveyor
|
2
2
|
====================
|
3
3
|
|
4
|
+
1.4.0
|
5
|
+
-----
|
6
|
+
### Features
|
7
|
+
|
8
|
+
- Routes are namespaced (e.g. `surveyor.available_surveys_path`) and may be mounted at a different root (e.g. `mount Surveyor::Engine, :at => '/instruments'`) (#398, #421)
|
9
|
+
- Surveyor::Parser.parse_file takes an options[:filename] parameter, used to locate translations (#429)
|
10
|
+
- Surveyor::Parser allows translations to be specified inline using a hash (#429)
|
11
|
+
- require locale of survey when translations are present (#426)
|
12
|
+
- locale selection in survey UI (#427)
|
13
|
+
|
14
|
+
### Fixes
|
15
|
+
|
16
|
+
- Remove default order on Response. (#423)
|
17
|
+
- Bug fix for RedCap Parser for DependencyConditions. thanks @ariel-perez-birchbox
|
18
|
+
- Make Surveyor::Parser accept Answer#reference_identifier via underscore or hash syntax (#439)
|
19
|
+
- Fix show action and have it use new translation view methods (#438, #442) thanks @alanjcfs
|
20
|
+
- Fix times showing in UTC when time zone is specified in Rails (#435)
|
21
|
+
|
22
|
+
### Dependencies
|
23
|
+
|
24
|
+
- Removing support for Rails 3.0. Applications requiring Rails 3.0 should use Surveyor v1.3.0
|
25
|
+
|
4
26
|
1.3.0
|
5
27
|
-----
|
6
28
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -40,7 +40,10 @@ task :testbed => 'testbed:rebuild'
|
|
40
40
|
namespace :testbed do
|
41
41
|
desc 'Generate a minimal surveyor-using rails app'
|
42
42
|
task :generate do
|
43
|
-
|
43
|
+
Tempfile.open('surveyor_Rakefile') do |f|
|
44
|
+
f.write("application \"config.time_zone='Rome'\"");f.flush
|
45
|
+
sh "bundle exec rails new testbed --skip-bundle -m #{f.path}" # don't run bundle install until the Gemfile modifications
|
46
|
+
end
|
44
47
|
chdir('testbed') do
|
45
48
|
gem_file_contents = File.read('Gemfile')
|
46
49
|
gem_file_contents.sub!(/^(gem 'rails'.*)$/, %Q{# \\1\nplugin_root = File.expand_path('../..', __FILE__)\neval(File.read File.join(plugin_root, 'Gemfile.rails_version'))\ngem 'surveyor', :path => plugin_root})
|
@@ -19,7 +19,7 @@
|
|
19
19
|
:as => rc_to_as(a.response_class),
|
20
20
|
:label => a.text_for(:pre, @render_context, I18n.locale).blank? ? false : a.text_for(:pre, @render_context, I18n.locale),
|
21
21
|
:hint => a.text_for(:post, @render_context, I18n.locale),
|
22
|
-
:input_html => generate_pick_none_input_html(r.
|
22
|
+
:input_html => generate_pick_none_input_html(r.to_formatted_s, a.default_value_for(@render_context, I18n.locale), a.css_class, a.response_class, disabled, a.input_mask, a.input_mask_placeholder)
|
23
23
|
- else
|
24
24
|
= a.text_for(nil, @render_context, I18n.locale)
|
25
25
|
%span.help= a.help_text_for(@render_context, I18n.locale) unless g && g.display_type == "grid"
|
@@ -1,5 +1,12 @@
|
|
1
1
|
.surveyor_menu
|
2
|
+
- if !@survey.translations.empty?
|
3
|
+
= hidden_field_tag "current_section", @section.id
|
4
|
+
.surveyor_language_selection
|
5
|
+
= label_tag "locale", t('surveyor.language')
|
6
|
+
%select{:id=>"locale", :name=>"new_locale"}
|
7
|
+
= options_for_select(@survey.translations.map(&:locale),I18n.locale)
|
8
|
+
|
2
9
|
= t('surveyor.sections')
|
3
10
|
%ul
|
4
11
|
- @sections.each do |s|
|
5
|
-
%li{:class => ("active" if s == @section)}= menu_button_for(s)
|
12
|
+
%li{:class => ("active" if s == @section)}= menu_button_for(s)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
.surveyor_flash
|
4
4
|
= flash_messages(types)
|
5
5
|
.close
|
6
|
-
= semantic_form_for(@response_set, :as => :r, :url => update_my_survey_path, :html => {:method => :put, :id => "survey_form", :class => @survey.custom_class}) do |f|
|
6
|
+
= semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:method => :put, :id => "survey_form", :class => @survey.custom_class}) do |f|
|
7
7
|
|
8
8
|
= hidden_field_tag :surveyor_javascript_enabled, false
|
9
9
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
%ul
|
10
10
|
- @surveys_by_access_code.each do |access_code, surveys|
|
11
11
|
%li
|
12
|
-
= form_tag take_survey_path(:survey_code => access_code) do
|
12
|
+
= form_tag surveyor.take_survey_path(:survey_code => access_code) do
|
13
13
|
= hidden_field_tag :surveyor_javascript_enabled, false
|
14
14
|
= surveys.first.translation(I18n.locale)[:title]
|
15
15
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
.surveyor_flash
|
4
4
|
= flash_messages(types)
|
5
5
|
.close
|
6
|
-
= semantic_form_for(@response_set, :as => :r, :url => update_my_survey_path, :html => {:id => "survey_form", :class => @survey.custom_class}) do |f|
|
6
|
+
= semantic_form_for(@response_set, :as => :r, :url => surveyor.update_my_survey_path, :html => {:id => "survey_form", :class => @survey.custom_class}) do |f|
|
7
7
|
.survey_title= @survey.title
|
8
8
|
- @survey.sections.each do |section|
|
9
9
|
= div_for section do
|
@@ -22,18 +22,18 @@
|
|
22
22
|
- if answered_questions.length > 0 # there are answered questions in this section or group
|
23
23
|
- g = q.question_group
|
24
24
|
- renderer = g.renderer
|
25
|
-
|
25
|
+
|
26
26
|
- unless label.blank?
|
27
27
|
= render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
|
28
28
|
- label = nil
|
29
|
-
= f.inputs
|
29
|
+
= f.inputs g.text_for(@render_context, I18n.locale), :id => "g_#{g.id}", :class => "g_#{renderer} #{g.css_class(@response_set)}" do
|
30
30
|
%li.help= g.help_text
|
31
31
|
- case renderer
|
32
32
|
- when :grid
|
33
33
|
%li
|
34
34
|
%table
|
35
35
|
%col.pre
|
36
|
-
- group_questions.first.answers.each do |a|
|
36
|
+
- group_questions.first.answers.each do |a|
|
37
37
|
%col{:class => cycle("odd", "even")}
|
38
38
|
%col.post
|
39
39
|
%tbody
|
@@ -41,17 +41,18 @@
|
|
41
41
|
%tr
|
42
42
|
%th
|
43
43
|
- ten_questions.first.answers.each do |a|
|
44
|
-
%th
|
44
|
+
%th
|
45
|
+
= a.text_for(nil, @render_context, I18n.locale)
|
46
|
+
%span.help= a.help_text_for(@render_context, I18n.locale)
|
45
47
|
%th
|
46
48
|
- ten_questions.each_with_index do |q, j|
|
47
49
|
%tr{:id => "q_#{q.id}", :class => "q_#{renderer} #{q.css_class(@response_set)}"}
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
%th= q.split(q.text, :pre)
|
50
|
+
%th
|
51
|
+
= q.text_for(:pre, @render_context, I18n.locale)
|
52
|
+
= q.help_text_for(@render_context, I18n.locale)
|
52
53
|
- q.answers.each do |a|
|
53
|
-
%td= render
|
54
|
-
%th= q.
|
54
|
+
%td= render(a.custom_renderer || '/partials/answer', :g => g, :q => q, :a => a, :f => f, :disableFlag => true) unless q.display_type == "label"
|
55
|
+
%th= q.text_for(:post, @render_context, I18n.locale)
|
55
56
|
- when :repeater
|
56
57
|
- (@response_set.count_group_responses(group_questions) + 1).times do |rg|
|
57
58
|
%li
|
@@ -59,19 +60,15 @@
|
|
59
60
|
= render q.custom_renderer || "/partials/question", :g => g, :rg => rg, :q => q, :f => f, :disableFlag => true
|
60
61
|
- else # :inline
|
61
62
|
- answered_questions.each do |q|
|
62
|
-
= render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f, :disableFlag => true
|
63
|
-
|
63
|
+
= render q.custom_renderer || "/partials/question", :g => g, :q => q, :f => f, :disableFlag => true
|
64
64
|
- group_questions = []
|
65
65
|
- answered_questions = []
|
66
|
-
- else
|
66
|
+
- else
|
67
67
|
- if q.display_type == 'label'
|
68
|
-
|
69
|
-
-
|
70
|
-
- unless label.blank?
|
71
|
-
= render q.custom_renderer || "/partials/question", :q => label, :f => f, :disableFlag => true
|
72
|
-
- label = nil
|
68
|
+
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
|
69
|
+
- elsif !(@response_set.responses.where(:question_id => q.id).empty?)
|
73
70
|
= render q.custom_renderer || "/partials/question", :q => q, :f => f, :disableFlag => true
|
74
71
|
- answered_count = answered_count + 1
|
75
72
|
- if (i+1 >= questions.size) and (answered_count == 0)
|
76
73
|
#{"--- No data ---"}
|
77
|
-
|
74
|
+
|
data/ci-exec.sh
CHANGED
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
match '
|
3
|
-
match '
|
4
|
-
match '
|
5
|
-
match '
|
6
|
-
match '
|
7
|
-
match '
|
1
|
+
Surveyor::Engine.routes.draw do
|
2
|
+
match '/', :to => 'surveyor#new', :as => 'available_surveys', :via => :get
|
3
|
+
match '/:survey_code', :to => 'surveyor#create', :as => 'take_survey', :via => :post
|
4
|
+
match '/:survey_code', :to => 'surveyor#export', :as => 'export_survey', :via => :get
|
5
|
+
match '/:survey_code/:response_set_code', :to => 'surveyor#show', :as => 'view_my_survey', :via => :get
|
6
|
+
match '/:survey_code/:response_set_code/take', :to => 'surveyor#edit', :as => 'edit_my_survey', :via => :get
|
7
|
+
match '/:survey_code/:response_set_code', :to => 'surveyor#update', :as => 'update_my_survey', :via => :put
|
8
8
|
end
|
@@ -8,7 +8,10 @@ Feature: Internationalization
|
|
8
8
|
Given I parse
|
9
9
|
"""
|
10
10
|
survey "One language is never enough" do
|
11
|
-
translations :
|
11
|
+
translations :en => :default
|
12
|
+
translations :es => {"title"=>"Un idioma nunca es suficiente", "survey_sections"=>{"one"=>{"title"=>"Uno"}}, "question_groups"=>{"hello"=>{"text"=>"¡Hola!"}}, "questions"=>{"name"=>{"text"=>"¿Cómo se llama Usted?", "answers"=>{"name"=>{"help_text"=>"Mi nombre es..."}}}}}
|
13
|
+
translations :he => {"title"=>"ידיעת שפה אחת אינה מספיקה", "survey_sections"=>{"one"=>{"title"=>"אחת"}}, "question_groups"=>{"hello"=>{"text"=>"שלום"}}, "questions"=>{"name"=>{"text"=>"מה שמך?", "answers"=>{"name"=>{"help_text"=>"שמי..."}}}}}
|
14
|
+
translations :ko => {"title"=>"한가지 언어로는 충분치 않습니다.", "survey_sections"=>{"one"=>{"title"=>"하나"}}, "question_groups"=>{"hello"=>{"text"=>"안녕하십니까"}}, "questions"=>{"name"=>{"text"=>"성함이 어떻게 되십니까?", "answers"=>{"name"=>{"help_text"=>"제 이름은 ... 입니다"}}}}}
|
12
15
|
section_one "One" do
|
13
16
|
g_hello "Hello" do
|
14
17
|
q_name "What is your name?"
|
@@ -17,39 +20,102 @@ Feature: Internationalization
|
|
17
20
|
end
|
18
21
|
end
|
19
22
|
"""
|
20
|
-
Then there should be
|
23
|
+
Then there should be 4 translations with
|
21
24
|
| locale |
|
25
|
+
| en |
|
22
26
|
| es |
|
23
27
|
| he |
|
24
28
|
| ko |
|
25
29
|
When I start the survey
|
26
30
|
Then I should see "One language is never enough"
|
31
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
32
|
+
And I should see "One"
|
33
|
+
And I should see "Hello"
|
34
|
+
And I should see "What is your name?"
|
35
|
+
And I should see "My name is..."
|
36
|
+
When I start the survey in "en"
|
37
|
+
Then I should see "One language is never enough"
|
38
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
27
39
|
And I should see "One"
|
28
40
|
And I should see "Hello"
|
29
41
|
And I should see "What is your name?"
|
30
42
|
And I should see "My name is..."
|
31
43
|
When I start the survey in "es"
|
32
44
|
Then I should see "Un idioma nunca es suficiente"
|
45
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
33
46
|
And I should see "Uno"
|
34
47
|
And I should see "¡Hola!"
|
35
48
|
And I should see "¿Cómo se llama Usted?"
|
36
49
|
And I should see "Mi nombre es..."
|
37
50
|
When I start the survey in "he"
|
38
51
|
Then I should see "ידיעת שפה אחת אינה מספיקה"
|
52
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
39
53
|
And I should see "אחת"
|
40
54
|
And I should see "שלום"
|
41
55
|
And I should see "מה שמך?"
|
42
56
|
And I should see "שמי..."
|
43
57
|
When I start the survey in "ko"
|
44
58
|
Then I should see "한가지 언어로는 충분치 않습니다."
|
59
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
45
60
|
And I should see "하나"
|
46
61
|
And I should see "안녕하십니까"
|
47
62
|
And I should see "성함이 어떻게 되십니까?"
|
48
63
|
And I should see "제 이름은 ... 입니다"
|
49
64
|
When I start the survey
|
50
65
|
Then I should see "One language is never enough"
|
66
|
+
And a dropdown should exist with the options "en, es, he, ko"
|
51
67
|
And I should see "One"
|
52
68
|
And I should see "Hello"
|
53
69
|
And I should see "What is your name?"
|
54
70
|
And I should see "My name is..."
|
55
71
|
|
72
|
+
|
73
|
+
Scenario:
|
74
|
+
Given I parse
|
75
|
+
"""
|
76
|
+
survey "Favorites" do
|
77
|
+
section "Foods" do
|
78
|
+
question_1 "What is the best meat?", :pick => :one, :correct => "oink"
|
79
|
+
a_oink "bacon"
|
80
|
+
a_tweet "chicken"
|
81
|
+
a_moo "beef"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
"""
|
85
|
+
When I start the survey
|
86
|
+
Then I should not see "Language"
|
87
|
+
|
88
|
+
@javascript
|
89
|
+
Scenario:
|
90
|
+
Given I parse
|
91
|
+
"""
|
92
|
+
survey "One language is never enough" do
|
93
|
+
translations :en => :default
|
94
|
+
translations :es => {"title"=>"Un idioma nunca es suficiente", "survey_sections"=>{"one"=>{"title"=>"Uno"}, "two"=>{"title"=>"Dos"}}, "question_groups"=>{"hello"=>{"text"=>"¡Hola!"}}, "questions"=>{"name"=>{"text"=>"¿Cómo se llama Usted?", "answers"=>{"name"=>{"help_text"=>"Mi nombre es..."}}}, "color"=>{"text"=>"¿Cuál es tu color favorito?"}}}
|
95
|
+
translations :he => {"title"=>"ידיעת שפה אחת אינה מספיקה", "survey_sections"=>{"one"=>{"title"=>"אחת"}, "two"=>{"title"=>"שנים"}}, "question_groups"=>{"hello"=>{"text"=>"שלום"}}, "questions"=>{"name"=>{"text"=>"מה שמך?", "answers"=>{"name"=>{"help_text"=>"שמי..."}}}, "color"=>{"text"=>"מהו הצבע האהוב עליך?"}}}
|
96
|
+
|
97
|
+
section_one "One" do
|
98
|
+
g_hello "Hello" do
|
99
|
+
q_name "What is your name?"
|
100
|
+
a_name :string, :help_text => "My name is..."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
section_two "Two" do
|
105
|
+
q_color "What is your favorite color?"
|
106
|
+
a_name :string
|
107
|
+
end
|
108
|
+
end
|
109
|
+
"""
|
110
|
+
When I start the survey in "en"
|
111
|
+
Then I should see "One language is never enough"
|
112
|
+
And I should see "What is your name?"
|
113
|
+
And I should see "Language"
|
114
|
+
And a dropdown should exist with the options "en, es, he"
|
115
|
+
When I change the locale to "es"
|
116
|
+
Then I should see "Un idioma nunca es suficiente"
|
117
|
+
And I should see "¿Cómo se llama Usted?"
|
118
|
+
When I press "Dos"
|
119
|
+
Then I should see "¿Cuál es tu color favorito?"
|
120
|
+
When I change the locale to "he"
|
121
|
+
Then I should see "מהו הצבע האהוב עליך?"
|
@@ -37,6 +37,35 @@ Feature: showing a survey
|
|
37
37
|
| orange |
|
38
38
|
| brown |
|
39
39
|
When I go to the last response set show page
|
40
|
+
Then I should see "You with the sad eyes don't be discouraged"
|
40
41
|
Then the "blue" radiobutton should be checked
|
41
42
|
And the "orange" checkbox should be checked
|
42
43
|
And the "brown" checkbox should be checked
|
44
|
+
|
45
|
+
Scenario: Take a survey with group questions, then look at it
|
46
|
+
Given I parse
|
47
|
+
"""
|
48
|
+
survey "Grid question test", :default_mandatory => false do
|
49
|
+
section 'Communication Skills' do
|
50
|
+
grid 'Identify communication and interviewing skills' do
|
51
|
+
a 'Yes'
|
52
|
+
a 'No'
|
53
|
+
|
54
|
+
q 'Able to articulate job duties and skills', :pick => :one
|
55
|
+
end
|
56
|
+
|
57
|
+
q 'Communication Skills Comments'
|
58
|
+
a :text
|
59
|
+
end
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
When I start the "Grid question test" survey
|
63
|
+
Then I should see "Identify communication and interviewing skills"
|
64
|
+
And I choose "Yes"
|
65
|
+
And I press "Click here to finish"
|
66
|
+
Then there should be 1 response set with 1 responses with:
|
67
|
+
| answer |
|
68
|
+
| Yes |
|
69
|
+
When I go to the last response set show page
|
70
|
+
Then I should see "Identify communication and interviewing skills"
|
71
|
+
Then the "Yes" radiobutton should be checked
|
@@ -88,7 +88,22 @@ end
|
|
88
88
|
|
89
89
|
Then /^there should be (\d+) resolved dependency_condition(?:s?) with:$/ do |x, table|
|
90
90
|
DependencyCondition.count.should == x.to_i
|
91
|
+
|
91
92
|
table.hashes.each do |hash|
|
93
|
+
if hash.has_key?("question_reference")
|
94
|
+
question = Question.find_by_reference_identifier(hash.delete("question_reference"))
|
95
|
+
question.should_not be_nil
|
96
|
+
|
97
|
+
hash.merge!({ :question_id => question.id })
|
98
|
+
|
99
|
+
if hash.has_key?("answer_reference")
|
100
|
+
answer = Answer.find(:first, :conditions => { :question_id => question.id, :reference_identifier => hash.delete("answer_reference") })
|
101
|
+
answer.should_not be_nil
|
102
|
+
|
103
|
+
hash.merge!({ :answer_id => answer.id })
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
92
107
|
d = DependencyCondition.find(:first, :conditions => hash)
|
93
108
|
d.should_not be_nil
|
94
109
|
d.question.should_not be_nil
|
@@ -18,10 +18,9 @@ When /^I start the survey$/ do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
When /^I start the survey in "(.*?)"$/ do |locale|
|
21
|
-
|
22
|
-
steps
|
23
|
-
|
24
|
-
}
|
21
|
+
step %Q{I go to the surveys page in "#{locale}"}
|
22
|
+
# these steps need to be separated so the url param has a chance to set I18n.locale
|
23
|
+
step %Q{I press "#{I18n.t 'surveyor.take_it'}"}
|
25
24
|
end
|
26
25
|
|
27
26
|
|
@@ -120,6 +119,7 @@ end
|
|
120
119
|
Then /^there should (not )?be a (\w+ )?response(?: for answer "([^"]+)")?(?: with value "([^"]+)")?(?: on question "([^"]+)")?$/ do |neg, type, answer_reference_id, value, question_reference_id|
|
121
120
|
conditions = []
|
122
121
|
values = []
|
122
|
+
where = {}
|
123
123
|
expected_count = neg.blank? ? 1 : 0
|
124
124
|
if type
|
125
125
|
attribute = case type.strip
|
@@ -132,10 +132,8 @@ Then /^there should (not )?be a (\w+ )?response(?: for answer "([^"]+)")?(?: wit
|
|
132
132
|
end
|
133
133
|
if value
|
134
134
|
case type.strip
|
135
|
-
when 'date'
|
136
|
-
|
137
|
-
conditions << "date(#{attribute}) = date(?)"
|
138
|
-
values << value
|
135
|
+
when 'date' || 'datetime' || 'time'
|
136
|
+
where[:datetime_value] = Time.zone.parse(value).utc
|
139
137
|
else
|
140
138
|
conditions << "#{attribute} = ?"
|
141
139
|
values << value
|
@@ -163,7 +161,7 @@ Then /^there should (not )?be a (\w+ )?response(?: for answer "([^"]+)")?(?: wit
|
|
163
161
|
values << answer
|
164
162
|
end
|
165
163
|
|
166
|
-
Response.where(conditions.join(' AND '), *values).count.should == expected_count
|
164
|
+
Response.where(conditions.join(' AND '), *values).where(where).count.should == expected_count
|
167
165
|
end
|
168
166
|
|
169
167
|
Then /^I should see the image "([^"]*)"$/ do |src|
|
@@ -321,3 +319,7 @@ end
|
|
321
319
|
Then /^I set the asset directory$/ do
|
322
320
|
ActionController::Base.helpers.config.assets_dir = "public" unless asset_pipeline_enabled?
|
323
321
|
end
|
322
|
+
|
323
|
+
When(/^I change the locale to "(.*?)"$/) do |locale|
|
324
|
+
steps %Q{When I select "#{locale}" from "new_locale"}
|
325
|
+
end
|
data/features/support/paths.rb
CHANGED
@@ -10,10 +10,13 @@ module NavigationHelpers
|
|
10
10
|
|
11
11
|
when /^the home\s?page$/
|
12
12
|
'/'
|
13
|
-
when
|
13
|
+
when /^the surveys page$/
|
14
14
|
'/surveys'
|
15
|
+
when /the surveys page in "(.*)"$/
|
16
|
+
"/surveys?locale=#{$1}"
|
15
17
|
when /the last response set show page/
|
16
|
-
|
18
|
+
"/surveys/#{ResponseSet.last.survey.access_code}/#{ResponseSet.last.access_code}"
|
19
|
+
|
17
20
|
# Add more mappings here.
|
18
21
|
# Here is an example that pulls values out of the Regexp:
|
19
22
|
#
|