Skip to content

Commit

Permalink
Merge branch '374_refactorTestsForTravis' of https://github.com/hpi-s…
Browse files Browse the repository at this point in the history
…wt2/workshop-portal into 374_refactorTestsForTravis
  • Loading branch information
Lennart L committed Jan 30, 2017
2 parents 84cd3b0 + d09a460 commit 780772b
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/models/profile.rb
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/views/profiles/_form_fields.html.erb
Expand Up @@ -24,6 +24,14 @@
</div>
</div>

<div class="form-group">
<%= f.label :discovery_of_site, :class => 'control-label col-lg-2' %>
<div class="col-lg-10">
<%= f.text_field :discovery_of_site, :class => 'form-control' %>
<%= f.error_span(:discovery_of_site) %>
</div>
</div>

<div class="text-right col-lg-12" >
<label class="required"> </label>
<%= t("errors.messages.required") %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/show.html.erb
Expand Up @@ -4,7 +4,7 @@
</div>

<dl class="dl-horizontal">
<% [: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| %>
<dt><strong><%= model_class.human_attribute_name(attr_name) %>:</strong></dt>
<% if attr_name == :gender %>
<dd><%= t("profiles.genders.#{@profile.public_send(attr_name)}") %></dd>
Expand Down
3 changes: 2 additions & 1 deletion config/locales/de.profiles.yml
Expand Up @@ -36,4 +36,5 @@ de:
state: "Bundesland"
country: "Land"
address: "Adresse"
graduates_school_in: "Abitur vorraussichtlich in"
graduates_school_in: "Abitur vorraussichtlich in"
discovery_of_site: "Wie hast du von uns erfahren?"
7 changes: 6 additions & 1 deletion config/locales/en.profiles.yml
Expand Up @@ -9,4 +9,9 @@ en:
genders:
male: "Male"
female: "Female"
other: "Other"
other: "Other"

activerecord:
attributes:
profile:
discovery_of_site: "How did you find out about us?"
@@ -0,0 +1,5 @@
class AddDiscoveryOfSiteToProfiles < ActiveRecord::Migration
def change
add_column :profiles, :discovery_of_site, :text
end
end
9 changes: 6 additions & 3 deletions db/sample_data/profiles.rb
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
5 changes: 3 additions & 2 deletions db/schema.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/factories/profiles.rb
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions spec/views/profiles/edit.html.erb_spec.rb
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/views/profiles/show.html.erb_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 780772b

Please sign in to comment.