Merge pull request #104 from Skud/public_email

Public email
This commit is contained in:
Joseph Caudle
2013-02-05 22:25:06 -08:00
10 changed files with 55 additions and 11 deletions

View File

@@ -14,8 +14,7 @@ class Member < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model
attr_accessible :login_name, :email, :password, :password_confirmation,
:remember_me, :login, :tos_agreement
# attr_accessible :title, :body
:remember_me, :login, :tos_agreement, :show_email
# Virtual attribute for authenticating by either username or email
# This is in addition to a real persisted field like 'username'

View File

@@ -11,6 +11,11 @@
= f.email_field :email
%span.help-inline If you change your email address you will have to reconfirm
.control-group
.controls
= f.check_box :show_email
Show email publicly on your profile page
%h2 Change password
.control-group

View File

@@ -22,7 +22,7 @@
.control-group
.controls
= f.check_box :tos_agreement
I agree to the
I agree to the
= link_to('Terms of Service', url_for(:action => 'tos', :controller => '/policy'))
.form-actions

View File

@@ -8,7 +8,12 @@
%p
= "Member since: #{@member.created_at.to_s(:date)}"
%p Location: Unknown
%p
Location: Unknown
- if @member.show_email
%p
Email:
= mail_to @member.email
.span9
.tabbable

View File

@@ -0,0 +1,5 @@
class AddShowEmailToMember < ActiveRecord::Migration
def change
add_column :members, :show_email, :boolean
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130118043431) do
ActiveRecord::Schema.define(:version => 20130206051328) do
create_table "crops", :force => true do |t|
t.string "system_name", :null => false
@@ -59,6 +59,7 @@ ActiveRecord::Schema.define(:version => 20130118043431) do
t.string "login_name"
t.string "slug"
t.boolean "tos_agreement"
t.boolean "show_email"
end
add_index "members", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true

View File

@@ -7,20 +7,24 @@ FactoryGirl.define do
email { generate(:email) }
tos_agreement true
confirmed_at Time.now
show_email false
factory :no_tos_member do
tos_agreement false
# email 'notos@example.com'
end
factory :unconfirmed_member do
confirmed_at nil
# email 'confirmed@example.com'
end
factory :long_name_member do
login_name 'Marmaduke Blundell-Hollinshead-Blundell-Tolemache-Plantagenet-Whistlebinkie, 3rd Duke of Marmoset'
# email 'marmaduke@example.com'
end
# this member has very loose privacy settings
factory :public_member do
login_name 'NothingToHide'
show_email true
end
end

View File

@@ -29,6 +29,11 @@ describe 'member' do
@member.gardens.count.should == 1
end
it "doesn't show email by default" do
@member.save
@member.show_email.should be_false
end
it 'should stringify as the login_name' do
@member.to_s.should == 'member1'
"#{@member}".should == 'member1'

View File

@@ -18,9 +18,14 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do
rendered.should contain 'Email'
end
it 'should have an email section' do
assert_select "h2", "Email address"
end
context 'email section'
it 'has a heading' do
assert_select "h2", "Email address"
end
it 'shows show_email checkbox' do
assert_select "input[id=member_show_email][type=checkbox]"
end
it 'should have a password section' do
assert_select "h2", "Change password"

View File

@@ -41,6 +41,10 @@ describe "members/show" do
rendered.should_not contain "Note: these are a random selection"
end
it "doesn't show the email address" do
rendered.should_not contain @member.email
end
context "signed in member" do
before(:each) do
sign_in @member
@@ -52,4 +56,15 @@ describe "members/show" do
end
end
context "public member" do
before(:each) do
@member = FactoryGirl.create(:public_member)
render
end
it "shows the email address" do
rendered.should contain @member.email
end
end
end