Browse files

parter output the survey question

  • Loading branch information...
1 parent 7bf7248 commit a503f9779076041e777fa12d427d1d6b0fdeeee6 Alex Mekelburg committed Jan 30, 2014
Showing with 23 additions and 14 deletions.
  1. +5 −4 app/services/v2/partner_service.rb
  2. +18 −10 spec/services/v2/partner_service_spec.rb
View
9 app/services/v2/partner_service.rb
@@ -52,10 +52,6 @@ def self.find(query, only_public = false)
:org_name => partner.organization,
:org_URL => partner.url,
:logo_image_URL => "https://#{RockyConf.pdf_host_name}#{partner.logo.url}",
- :survey_question_1_en => partner.survey_question_1_en,
- :survey_question_2_en => partner.survey_question_2_en,
- :survey_question_1_es => partner.survey_question_1_es,
- :survey_question_2_es => partner.survey_question_2_es,
:whitelabeled => partner.whitelabeled?,
:rtv_ask_email_opt_in => partner.rtv_email_opt_in?,
:partner_ask_email_opt_in => partner.partner_email_opt_in?,
@@ -64,6 +60,11 @@ def self.find(query, only_public = false)
:rtv_ask_volunteer => partner.ask_for_volunteers?,
:partner_ask_volunteer => partner.partner_ask_for_volunteers?
}
+
+ RockyConf.enabled_locales.each do |loc|
+ data["survey_question_1_#{loc}".to_sym] = partner.send("survey_question_1_#{loc}")
+ data["survey_question_2_#{loc}".to_sym] = partner.send("survey_question_2_#{loc}")
+ end
if only_public
data.merge!({
View
28 spec/services/v2/partner_service_spec.rb
@@ -43,7 +43,7 @@
end
it 'should return all data' do
partner = FactoryGirl.create(:whitelabel_partner)
- V2::PartnerService.find(:partner_id => partner.id, :partner_api_key => partner.api_key).should == {
+ expected_response = {
:org_name => partner.organization,
:org_URL => partner.url,
:contact_name => partner.name,
@@ -54,10 +54,6 @@
:contact_state => partner.state_abbrev,
:contact_ZIP => partner.zip_code,
:logo_image_URL => "https://#{RockyConf.pdf_host_name}#{partner.logo.url}",
- :survey_question_1_en => partner.survey_question_1_en,
- :survey_question_2_en => partner.survey_question_2_en,
- :survey_question_1_es => partner.survey_question_1_es,
- :survey_question_2_es => partner.survey_question_2_es,
:whitelabeled => partner.whitelabeled?,
:rtv_ask_email_opt_in => partner.rtv_email_opt_in?,
:partner_ask_email_opt_in => partner.partner_email_opt_in?,
@@ -66,19 +62,24 @@
:rtv_ask_volunteer => partner.ask_for_volunteers?,
:partner_ask_volunteer => partner.partner_ask_for_volunteers?
}
+
+ RockyConf.enabled_locales.each do |loc|
+ expected_response["survey_question_1_#{loc}".to_sym] = partner.send("survey_question_1_#{loc}")
+ expected_response["survey_question_2_#{loc}".to_sym] = partner.send("survey_question_2_#{loc}")
+ end
+
+ V2::PartnerService.find(:partner_id => partner.id, :partner_api_key => partner.api_key).should == expected_response
+
end
it 'should return only public data' do
partner = FactoryGirl.create(:whitelabel_partner)
- V2::PartnerService.find({ :partner_id => partner.id, :partner_api_key => partner.api_key }, true).should == {
+
+ expected_response = {
:org_name => partner.organization,
:org_URL => partner.url,
:org_privacy_url => partner.privacy_url,
:logo_image_URL => "https://#{RockyConf.pdf_host_name}#{partner.logo.url}",
- :survey_question_1_en => partner.survey_question_1_en,
- :survey_question_2_en => partner.survey_question_2_en,
- :survey_question_1_es => partner.survey_question_1_es,
- :survey_question_2_es => partner.survey_question_2_es,
:whitelabeled => partner.whitelabeled?,
:rtv_ask_email_opt_in => partner.rtv_email_opt_in?,
:partner_ask_email_opt_in => partner.partner_email_opt_in?,
@@ -87,6 +88,13 @@
:rtv_ask_volunteer => partner.ask_for_volunteers?,
:partner_ask_volunteer => partner.partner_ask_for_volunteers?
}
+
+ RockyConf.enabled_locales.each do |loc|
+ expected_response["survey_question_1_#{loc}".to_sym] = partner.send("survey_question_1_#{loc}")
+ expected_response["survey_question_2_#{loc}".to_sym] = partner.send("survey_question_2_#{loc}")
+ end
+
+ V2::PartnerService.find({ :partner_id => partner.id, :partner_api_key => partner.api_key }, true).should == expected_response
end
end

0 comments on commit a503f97

Please sign in to comment.