From b927f54106d696ad885b02b6d3a55863f14a913f Mon Sep 17 00:00:00 2001 From: Fabian-Sommer Date: Mon, 30 Jan 2017 12:20:02 +0100 Subject: [PATCH] 179 4.13 Added discovery_of_site field to profile (#435) * Added discovery_of_site field to profile * Pushing migration --- app/models/profile.rb | 2 +- app/views/profiles/_form_fields.html.erb | 8 ++++++++ app/views/profiles/show.html.erb | 2 +- config/locales/de.profiles.yml | 3 ++- config/locales/en.profiles.yml | 7 ++++++- .../20170128122851_add_discovery_of_site_to_profiles.rb | 5 +++++ db/sample_data/profiles.rb | 9 ++++++--- db/schema.rb | 5 +++-- spec/factories/profiles.rb | 1 + spec/views/profiles/edit.html.erb_spec.rb | 1 + spec/views/profiles/show.html.erb_spec.rb | 2 +- 11 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20170128122851_add_discovery_of_site_to_profiles.rb diff --git a/app/models/profile.rb b/app/models/profile.rb index 89207f87..a21d879b 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -65,7 +65,7 @@ def address # @param none # @return [Symbol] List of parameters def self.allowed_params - [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in] + [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in, :discovery_of_site] end private diff --git a/app/views/profiles/_form_fields.html.erb b/app/views/profiles/_form_fields.html.erb index 81d990f7..a5d4fcda 100644 --- a/app/views/profiles/_form_fields.html.erb +++ b/app/views/profiles/_form_fields.html.erb @@ -24,6 +24,14 @@ +
+ <%= f.label :discovery_of_site, :class => 'control-label col-lg-2' %> +
+ <%= f.text_field :discovery_of_site, :class => 'form-control' %> + <%= f.error_span(:discovery_of_site) %> +
+
+
<%= t("errors.messages.required") %> diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index fee7ad36..a130937f 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -4,7 +4,7 @@
- <% [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in].each do |attr_name| %> + <% [:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in, :discovery_of_site].each do |attr_name| %>
<%= model_class.human_attribute_name(attr_name) %>:
<% if attr_name == :gender %>
<%= t("profiles.genders.#{@profile.public_send(attr_name)}") %>
diff --git a/config/locales/de.profiles.yml b/config/locales/de.profiles.yml index 54912ef9..59678f81 100644 --- a/config/locales/de.profiles.yml +++ b/config/locales/de.profiles.yml @@ -36,4 +36,5 @@ de: state: "Bundesland" country: "Land" address: "Adresse" - graduates_school_in: "Abitur vorraussichtlich in" \ No newline at end of file + graduates_school_in: "Abitur vorraussichtlich in" + discovery_of_site: "Wie hast du von uns erfahren?" \ No newline at end of file diff --git a/config/locales/en.profiles.yml b/config/locales/en.profiles.yml index 4a1f6924..3d0c2b13 100644 --- a/config/locales/en.profiles.yml +++ b/config/locales/en.profiles.yml @@ -9,4 +9,9 @@ en: genders: male: "Male" female: "Female" - other: "Other" \ No newline at end of file + other: "Other" + + activerecord: + attributes: + profile: + discovery_of_site: "How did you find out about us?" \ No newline at end of file diff --git a/db/migrate/20170128122851_add_discovery_of_site_to_profiles.rb b/db/migrate/20170128122851_add_discovery_of_site_to_profiles.rb new file mode 100644 index 00000000..18dab880 --- /dev/null +++ b/db/migrate/20170128122851_add_discovery_of_site_to_profiles.rb @@ -0,0 +1,5 @@ +class AddDiscoveryOfSiteToProfiles < ActiveRecord::Migration + def change + add_column :profiles, :discovery_of_site, :text + end +end diff --git a/db/sample_data/profiles.rb b/db/sample_data/profiles.rb index a9c35dd6..43893f24 100644 --- a/db/sample_data/profiles.rb +++ b/db/sample_data/profiles.rb @@ -28,7 +28,8 @@ def profile_pupil_max(user) city: "Potsdam", state: "Brandenburg", country: "Deutschland", - graduates_school_in: "2018" + graduates_school_in: "2018", + discovery_of_site: "Mein Lehrer hat mir davon erzählt" ) end @@ -45,7 +46,8 @@ def profile_teacher(user) city: "Potsdam", state: "Brandenburg", country: "Deutschland", - graduates_school_in: "Bereits Abitur" + graduates_school_in: "Bereits Abitur", + discovery_of_site: "Werbung im Internet" ) end @@ -62,7 +64,8 @@ def profile_applicant(user) city: "Potsdam", state: "Brandenburg", country: "Deutschland", - graduates_school_in: "2017" + graduates_school_in: "2017", + discovery_of_site: "Von meinem Bruder" ) end diff --git a/db/schema.rb b/db/schema.rb index 0919a210..88caa37c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170123161527) do +ActiveRecord::Schema.define(version: 20170128122851) do create_table "agreement_letters", force: :cascade do |t| t.integer "user_id", null: false @@ -112,6 +112,7 @@ t.string "state" t.string "country" t.string "graduates_school_in" + t.text "discovery_of_site" end add_index "profiles", ["user_id"], name: "index_profiles_on_user_id" @@ -130,8 +131,8 @@ t.integer "number_of_participants" t.string "knowledge_level" t.text "annotations" - t.string "zip_code_city" t.integer "status", default: 0 + t.string "zip_code_city" t.string "contact_person" end diff --git a/spec/factories/profiles.rb b/spec/factories/profiles.rb index 9ea57a5d..a60148cc 100644 --- a/spec/factories/profiles.rb +++ b/spec/factories/profiles.rb @@ -21,6 +21,7 @@ state "Babelsberg" country "Deutschland" graduates_school_in "Bereits Abitur" + discovery_of_site "Google" user trait :low_values do first_name "Andreas" diff --git a/spec/views/profiles/edit.html.erb_spec.rb b/spec/views/profiles/edit.html.erb_spec.rb index 5772a2ac..e2e37ace 100644 --- a/spec/views/profiles/edit.html.erb_spec.rb +++ b/spec/views/profiles/edit.html.erb_spec.rb @@ -20,6 +20,7 @@ assert_select "input#profile_state[name=?]", "profile[state]" assert_select "input#profile_country[name=?]", "profile[country]" assert_select "select#profile_graduates_school_in[name=?]", "profile[graduates_school_in]" + assert_select "input#profile_discovery_of_site[name=?]", "profile[discovery_of_site]" end end diff --git a/spec/views/profiles/show.html.erb_spec.rb b/spec/views/profiles/show.html.erb_spec.rb index e3483783..9b47a9f9 100644 --- a/spec/views/profiles/show.html.erb_spec.rb +++ b/spec/views/profiles/show.html.erb_spec.rb @@ -7,7 +7,7 @@ it "renders attributes" do render - [:first_name, :last_name, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in].each do |attr_name| + [:first_name, :last_name, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in, :discovery_of_site].each do |attr_name| expect(rendered).to have_text(@profile.public_send(attr_name)) end end