From 07efe0dc8d1b2f4aecc43f46fdb1e3cbc509f9c5 Mon Sep 17 00:00:00 2001 From: martyhines Date: Thu, 8 Aug 2013 22:18:18 -0400 Subject: [PATCH] Added bio to the member profile --- app/views/devise/registrations/edit.html.haml | 4 ++++ app/views/members/show.html.haml | 5 +++++ spec/factories/member.rb | 5 +++++ spec/views/devise/registrations/edit_spec.rb | 8 ++++++++ spec/views/members/show.html.haml_spec.rb | 16 ++++++++++++++++ 5 files changed, 38 insertions(+) diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index 4d97f7aa1..520704544 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -39,6 +39,10 @@ =f.text_field :location %span.help-inline This will be displayed on a map. You can be as detailed or vague as you like. + .control-group + =f.label :bio, :class => 'control-label' + .controls + =f.text_area :bio, :rows => 6, :class => 'input-block-level' %h2 Linked accounts diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 84808bda6..f52c5028d 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -56,6 +56,11 @@ - if can? :update, @member %p = link_to 'Edit your profile', "edit", :class => 'btn btn-primary' + - if @member.bio + %h2 Bio + :markdown + #{ strip_tags @member.bio } + %h2 Gardens .tabbable %ul.nav.nav-tabs - first_garden = true diff --git a/spec/factories/member.rb b/spec/factories/member.rb index 5e5b7f455..f1bac1392 100644 --- a/spec/factories/member.rb +++ b/spec/factories/member.rb @@ -9,11 +9,16 @@ FactoryGirl.define do tos_agreement true confirmed_at Time.now show_email false + bio 'I love seeds' factory :no_tos_member do tos_agreement false end + factory :no_bio_member do + bio nil + end + factory :unconfirmed_member do confirmed_at nil end diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 594bb9657..2f3981fc6 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -40,15 +40,23 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do it 'has a heading' do assert_select "h2", "Profile details" end + it 'shows show_email checkbox' do assert_select "input[id=member_show_email][type=checkbox]" end + it "contains a gravatar icon" do assert_select "img", :src => /gravatar\.com\/avatar/ end + it 'contains a link to gravatar.com' do assert_select "a", :href => /gravatar\.com/ end + + it 'shows bio field' do + assert_select "textarea[id=member_bio]" + end + it 'shows location field' do assert_select "input[id=member_location][type=text]" end diff --git a/spec/views/members/show.html.haml_spec.rb b/spec/views/members/show.html.haml_spec.rb index 4c3c66e15..76e8e8d01 100644 --- a/spec/views/members/show.html.haml_spec.rb +++ b/spec/views/members/show.html.haml_spec.rb @@ -12,6 +12,11 @@ describe "members/show" do render end + it "shows the bio" do + assert_select "h2", "Bio" + rendered.should contain @member.bio + end + it "shows account creation date" do @time = @member.created_at rendered.should contain "Member since" @@ -27,6 +32,17 @@ describe "members/show" do end end + context 'no bio' do + before(:each) do + @member = FactoryGirl.create(:no_bio_member) + render + end + + it "doesn't show the bio" do + rendered.should_not contain "Bio" + end + end + context 'twitter' do context "no twitter" do it "doesn't show twitter link" do