From 0b47c60952e9114602f80040db5af2daf875d152 Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 03:44:54 +0000 Subject: [PATCH 01/12] Added a page for the TOS --- app/controllers/policy_controller.rb | 2 ++ app/views/policy/tos.html.haml | 1 + config/routes.rb | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 app/controllers/policy_controller.rb create mode 100644 app/views/policy/tos.html.haml diff --git a/app/controllers/policy_controller.rb b/app/controllers/policy_controller.rb new file mode 100644 index 000000000..91127ca5a --- /dev/null +++ b/app/controllers/policy_controller.rb @@ -0,0 +1,2 @@ +class PolicyController < ApplicationController +end diff --git a/app/views/policy/tos.html.haml b/app/views/policy/tos.html.haml new file mode 100644 index 000000000..35066b34d --- /dev/null +++ b/app/views/policy/tos.html.haml @@ -0,0 +1 @@ +This is a placeholder for the Terms of Service diff --git a/config/routes.rb b/config/routes.rb index d819a87f6..c57c2bd7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -65,4 +65,7 @@ Growstuff::Application.routes.draw do # This is a legacy wild controller route that's not recommended for RESTful applications. # Note: This route will make all actions in every controller accessible via GET requests. # match ':controller(/:action(/:id))(.:format)' + + match '/policy/:action' => 'policy#:action' + end From f2bb4ecb58107965b013aed865f7613af4334fa2 Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 03:55:25 +0000 Subject: [PATCH 02/12] Added a migration for the TOS agreement boolean field --- db/migrate/20121203034745_add_tos_agreement_to_users.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/migrate/20121203034745_add_tos_agreement_to_users.rb diff --git a/db/migrate/20121203034745_add_tos_agreement_to_users.rb b/db/migrate/20121203034745_add_tos_agreement_to_users.rb new file mode 100644 index 000000000..aacc06970 --- /dev/null +++ b/db/migrate/20121203034745_add_tos_agreement_to_users.rb @@ -0,0 +1,5 @@ +class AddTosAgreementToUsers < ActiveRecord::Migration + def change + add_column :users, :tos_agreement, :boolean + end +end From 2df881bff6836bda8c9c380075cf56fc37c425d8 Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 04:15:33 +0000 Subject: [PATCH 03/12] Update schema for new TOS agreement field --- db/schema.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 4dc9cffed..df86c532a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20121109130033) do +ActiveRecord::Schema.define(:version => 20121203034745) do create_table "crops", :force => true do |t| t.string "system_name", :null => false @@ -63,6 +63,7 @@ ActiveRecord::Schema.define(:version => 20121109130033) do t.datetime "updated_at", :null => false t.string "username" t.string "slug" + t.boolean "tos_agreement" end add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true From 9f1adae2387adb39800dcdc15092eb33c3b633ed Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 04:17:37 +0000 Subject: [PATCH 04/12] Made the signup form look better using bootstrap --- app/views/devise/registrations/new.html.haml | 34 +++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 78638721a..fdc4d4d95 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -1,29 +1,25 @@ - content_for :title, "Sign up" -= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| += form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => "form-horizontal"}) do |f| = devise_error_messages! - %div - = f.label :username - %br - = f.text_field :username + .control-group + = f.label :username, :class => "control-label" + .controls= f.text_field :username - %div - = f.label :email - %br - = f.email_field :email + .control-group + = f.label :email, :class => "control-label" + .controls= f.email_field :email - %div - = f.label :password - %br - = f.password_field :password + .control-group + = f.label :password, :class => "control-label" + .controls= f.password_field :password - %div - = f.label :password_confirmation - %br - = f.password_field :password_confirmation + .control-group + = f.label :password_confirmation, :class => "control-label" + .controls= f.password_field :password_confirmation - %div - = f.submit "Sign up" + .form-actions + = f.submit "Sign up", :class => 'btn' = render "devise/shared/links" From e39ec4c5f8899bc766a45fd3223019b9ac3b4f8b Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 05:02:35 +0000 Subject: [PATCH 05/12] Added Tos field to the signup form --- app/views/devise/registrations/new.html.haml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index fdc4d4d95..cd14dd8d8 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -19,6 +19,12 @@ = f.label :password_confirmation, :class => "control-label" .controls= f.password_field :password_confirmation + .control-group + .controls + = f.check_box :tos_agreement + I agree to the + = link_to('Terms of Service', url_for(:action => 'tos', :controller => '/policy')) + .form-actions = f.submit "Sign up", :class => 'btn' From 12b3bdd432ff8d55d37e14ec9e2a4071eee5d56d Mon Sep 17 00:00:00 2001 From: Gnat Date: Mon, 3 Dec 2012 05:22:30 +0000 Subject: [PATCH 06/12] Added validation for TOS agreement Tests are currently broken, will fix later --- app/models/user.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 31f46227d..b19dd4d74 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -13,13 +13,17 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :username, :email, :password, :password_confirmation, - :remember_me, :login + :remember_me, :login, :tos_agreement # attr_accessible :title, :body # Virtual attribute for authenticating by either username or email # This is in addition to a real persisted field like 'username' attr_accessor :login + # Requires acceptance of the Terms of Service + validates_acceptance_of :tos_agreement, :allow_nil => false, + :accept => true + # allow login via either username or email address def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup From d95f034677f5fe0440564c91d7a1c571415d5305 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:02:35 +1100 Subject: [PATCH 07/12] Tweaked the gemfile so that 'rake' would run cleanly. (Was anyone else having that problem with rake versions?) --- Gemfile | 2 +- Gemfile.lock | 4 ++-- db/schema.rb | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index d79be4a42..8822cbc39 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ gem 'friendly_id' # for phusion passenger (i.e. mod_rails) on the server gem 'passenger' -gem 'rake' +gem 'rake', '>= 10.0.0' gem 'cape' gem 'diff-lcs' diff --git a/Gemfile.lock b/Gemfile.lock index a1f1b6f70..fabbee2d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -133,7 +133,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (0.9.2.2) + rake (10.0.2) rdoc (3.12) json (~> 1.4) rspec (2.11.0) @@ -206,7 +206,7 @@ DEPENDENCIES passenger pg rails (= 3.2.8) - rake + rake (>= 10.0.0) rspec-rails rvm-capistrano sass-rails (~> 3.2.3) diff --git a/db/schema.rb b/db/schema.rb index df86c532a..e7e80de28 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -24,6 +24,17 @@ ActiveRecord::Schema.define(:version => 20121203034745) do add_index "crops", ["slug"], :name => "index_crops_on_slug", :unique => true add_index "crops", ["system_name"], :name => "index_crops_on_system_name" + create_table "gardens", :force => true do |t| + t.string "name", :null => false + t.integer "user_id" + t.string "slug", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "gardens", ["slug"], :name => "index_gardens_on_slug", :unique => true + add_index "gardens", ["user_id"], :name => "index_gardens_on_user_id" + create_table "scientific_names", :force => true do |t| t.string "scientific_name", :null => false t.integer "crop_id", :null => false From 64724231e944ccdbf016fe4749403deda9f66ba0 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:13:08 +1100 Subject: [PATCH 08/12] Fixed tests to work with TOS agreement --- spec/models/user_spec.rb | 46 +++++++++++++++------- spec/support/controller_macros.rb | 8 +++- spec/views/updates/index.html.haml_spec.rb | 3 +- spec/views/updates/show.html.haml_spec.rb | 8 +++- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 19611123a..97e8e22c2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,24 +2,40 @@ require 'spec_helper' describe 'user' do - before(:each) do - @user = User.new - @user.email = "example@example.com" - @user.username = "someone" - @user.password = "irrelevant" + context 'valid user' do + before(:each) do + @user = User.new + @user.email = "example@example.com" + @user.username = "someone" + @user.password = "irrelevant" + @user.tos_agreement = true + end + + it 'should save a basic user' do + @user.save.should be_true + end + + it 'should be fetchable from the database' do + @user.save + @user2 = User.find_by_email('example@example.com') + @user2.email.should == "example@example.com" + @user2.username.should == "someone" + @user2.slug.should == "someone" + @user2.encrypted_password.should_not be_nil + end end - it 'should save a basic user' do - @user.save.should be_true - end + context 'no TOS agreement' do + before(:each) do + @user = User.new + @user.email = "example@example.com" + @user.username = "someone" + @user.password = "irrelevant" + end - it 'should be fetchable from the database' do - @user.save - @user2 = User.find_by_email('example@example.com') - @user2.email.should == "example@example.com" - @user2.username.should == "someone" - @user2.slug.should == "someone" - @user2.encrypted_password.should_not be_nil + it "should refuse to save a user who hasn't agreed to the TOS" do + @user.save.should_not be_true + end end end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index 98b604b63..a5c56a521 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -3,8 +3,12 @@ module ControllerMacros def login_user before(:each) do @request.env["devise.mapping"] = Devise.mappings[:user] - user = User.create! :username => "fred", :email => "fred@example.com", - :password => "Yabba-dabba-doo" + user = User.create!( + :username => "fred", + :email => "fred@example.com", + :password => "Yabba-dabba-doo", + :tos_agreement => true + ) user.confirm! sign_in user end diff --git a/spec/views/updates/index.html.haml_spec.rb b/spec/views/updates/index.html.haml_spec.rb index edd697730..591b53d1c 100644 --- a/spec/views/updates/index.html.haml_spec.rb +++ b/spec/views/updates/index.html.haml_spec.rb @@ -5,7 +5,8 @@ describe "updates/index" do user = User.create!( :username => "test_user", :email => "test@growstuff.org", - :password => "password" + :password => "password", + :tos_agreement => true ) assign(:updates, [ stub_model(Update, diff --git a/spec/views/updates/show.html.haml_spec.rb b/spec/views/updates/show.html.haml_spec.rb index 772cdfeb4..a35266b52 100644 --- a/spec/views/updates/show.html.haml_spec.rb +++ b/spec/views/updates/show.html.haml_spec.rb @@ -2,8 +2,12 @@ require 'spec_helper' describe "updates/show" do before(:each) do - @user = User.create! :username => "test_user", :email => "test@example.com", - :password => "password" + @user = User.create!( + :username => "test_user", + :email => "test@example.com", + :password => "password", + :tos_agreement => true + ) end it "renders the post" do From 83d332a82529423689bd55505c1e0e185a484fa0 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:28:05 +1100 Subject: [PATCH 09/12] Added the actual text of the TOS to the TOS view --- app/views/policy/tos.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/policy/tos.html.haml b/app/views/policy/tos.html.haml index 35066b34d..19f6ae1d1 100644 --- a/app/views/policy/tos.html.haml +++ b/app/views/policy/tos.html.haml @@ -1 +1,7 @@ -This is a placeholder for the Terms of Service +-content_for :title, 'Growstuff Terms of Service' + +:markdown + 1. Growstuff is currently UNDER DEVELOPMENT and is not a complete or reliable service. By signing up for an account, you recognise that this is the case, and that Growstuff may lose, mangle, or incorrectly use any data you enter, up to and including deleting your entire account and everything associated with it. + 1. You are strongly advised to sign up for our [Mailing list](http://wiki.growstuff.org/index.php/Mailing_list) to keep up with developments on the Growstuff site, and to follow discussions there for information about changes, updates, etc. + 1. As a member of Growstuff, you agree to abide by our #{link_to('Community Guidelines', url_for(:controller => 'policy', :action => 'community'))}. + 1. Any changes to this Terms of Service document or related policies (eg. the Community Guidelines) can be tracked at [http://github.com/Growstuff/policy](http://github.com/Growstuff/policy). To be notified of changes to our policies, sign up for a github account and "watch" this repository. From 382128c511c9bf41919cc2c0651b1c237b4c2e60 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:37:20 +1100 Subject: [PATCH 10/12] Added community guidelines to the app, plus tests --- app/views/policy/community.html.haml | 27 +++++++++++++++++++++++++++ spec/views/policy/community_spec.rb | 12 ++++++++++++ spec/views/policy/tos_spec.rb | 12 ++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 app/views/policy/community.html.haml create mode 100644 spec/views/policy/community_spec.rb create mode 100644 spec/views/policy/tos_spec.rb diff --git a/app/views/policy/community.html.haml b/app/views/policy/community.html.haml new file mode 100644 index 000000000..6011c9b4b --- /dev/null +++ b/app/views/policy/community.html.haml @@ -0,0 +1,27 @@ +-content_for :title, 'Growstuff Community Guidelines' + +:markdown + + Growstuff is a community by and for food-gardeners. Together, we are building a website where we can share our experience, knowledge, and the products of our harvest. The most important thing about Growstuff is the people. For Growstuff to thrive, we need people to add their crops, share their knowledge, and help build the site itself. + + Whatever your interest in Growstuff you are welcome here, and will be treated with respect. In particular: + + - We welcome people of any age, gender identity or expression, ethnicity, nationality, religion or absence thereof, political opinion, sexual orientation, marital status, family structure, ability or disability, appearance, subculture, or other identity or self-identification. + + - Although Growstuff is primarily focused on food gardening, we welcome all kinds of gardeners, including organic and conventional growers; those who grow their crops in fields or on balconies or in hydroponic systems; those who garden commercially or non-commercially; those who subsist on their crops and those who garden for other reasons. + + - We welcome people of all skill and experience levels, and we don't believe in being dismissive or commenting rudely just because you are new or learning. + + - Every role in our community is important, including gardeners who contribute skills, knowledge, and information to our site; coders, designers and other techies who help build it; moderators and others who help our community thrive; or any other form of participation. We believe in working together, and prioritise communication and mutual understanding. + + If you want to participate in the Growstuff community (which includes our website and any auxiliary forums such as our mailing list(s), IRC channel, etc), you need to agree to our general commitment to inclusiveness and mutual respect, as well as to the following specific policies: + + - Harassment of any Growstuff community member is forbidden. Harassment includes slurs directed at individuals or groups; unwanted sexual remarks directed at any person or group; sexually explicit comments or imagery in public spaces; stalking or other repeated, unwanted contact; or any repeated or sustained behaviour which disrupts someone else's enjoyment of the Growstuff site or community. + + - The privacy of our community members is very important. You may not disclose any member's personal details (including names by which they are known outside of Growstuff, their location, employment details, family details, outside-of-Growstuff contact details, or any other identifying or personal information) without their explicit consent. + + - Although we let you choose your own name on our site, and don't insist that you use the same name on our website as you have on the cards in your wallet, you're not allowed to create or use a pseudonymous account to mislead people, evade accountability, or otherwise cause trouble. (This is commonly known as a "sockpuppet" account.) + + If you experience or witness behaviour that goes against these community guidelines, you can report it to support@growstuff.org. We will listen carefully and take your report seriously. Once we've looked into the situation, we may take any action we deem necessary. For instance, we may issue a warning, or in serious cases we may suspend or ban people from our community. If this happens, we will always tell the person affected the reason for our action, with reference to our policy documents. + + We don't want to make these guidelines too long or legalistic, so we'll leave it there, except for one final guideline. As Bill and Ted said: *be excellent to each other*. And grow stuff. diff --git a/spec/views/policy/community_spec.rb b/spec/views/policy/community_spec.rb new file mode 100644 index 000000000..34026fbc3 --- /dev/null +++ b/spec/views/policy/community_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'policy/community.html.haml', :type => "view" do + before(:each) do + render + end + + it 'should show community guidelines' do + render + rendered.should contain 'Growstuff is a community by and for food-gardeners.' + end +end diff --git a/spec/views/policy/tos_spec.rb b/spec/views/policy/tos_spec.rb new file mode 100644 index 000000000..548deadc3 --- /dev/null +++ b/spec/views/policy/tos_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'policy/tos.html.haml', :type => "view" do + before(:each) do + render + end + + it 'should show terms of service' do + render + rendered.should contain 'Terms of Service' + end +end From 7ed0a7578856badc0700782a15a57cd724bfadfe Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:43:45 +1100 Subject: [PATCH 11/12] Added TOS link to footer --- app/views/layouts/_footer.html.haml | 3 ++- spec/views/layouts/_footer_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 88a559e35..a858f5d3f 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -3,8 +3,9 @@ .navbar-inner %ul.nav %li= link_to "About", "http://wiki.growstuff.org" + %li= link_to "Terms of Service", url_for(:controller => '/policy', :action => 'tos') + %li= link_to "Community Guidelines", url_for(:controller => '/policy', :action => 'community') %li= link_to "License", "https://github.com/Growstuff/growstuff/blob/dev/LICENSE.txt" %li= link_to "Github", "https://github.com/Growstuff/" %li= link_to "Wiki", "http://wiki.growstuff.org" %li= link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" - %li= link_to "Community Guidelines", "https://github.com/Growstuff/policy/blob/master/community-guidelines.md" diff --git a/spec/views/layouts/_footer_spec.rb b/spec/views/layouts/_footer_spec.rb index 79b76da68..b1a246929 100644 --- a/spec/views/layouts/_footer_spec.rb +++ b/spec/views/layouts/_footer_spec.rb @@ -8,10 +8,11 @@ describe 'layouts/_footer.html.haml', :type => "view" do it 'should have links in footer' do rendered.should contain 'About' + assert_select("a[href=#{'/policy/tos'}]", 'Terms of Service') + assert_select("a[href=#{'/policy/community'}]", 'Community Guidelines') rendered.should contain 'License' rendered.should contain 'Github' rendered.should contain 'Wiki' rendered.should contain 'Mailing list' - rendered.should contain 'Community Guidelines' end end From a0855fd563c3b25393b65f4f5c17057acf4dc125 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 5 Dec 2012 16:47:10 +1100 Subject: [PATCH 12/12] Removed wiki link in footer ("About" goes there already) --- app/views/layouts/_footer.html.haml | 1 - spec/views/layouts/_footer_spec.rb | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index a858f5d3f..aaada0967 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -7,5 +7,4 @@ %li= link_to "Community Guidelines", url_for(:controller => '/policy', :action => 'community') %li= link_to "License", "https://github.com/Growstuff/growstuff/blob/dev/LICENSE.txt" %li= link_to "Github", "https://github.com/Growstuff/" - %li= link_to "Wiki", "http://wiki.growstuff.org" %li= link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" diff --git a/spec/views/layouts/_footer_spec.rb b/spec/views/layouts/_footer_spec.rb index b1a246929..b4e6e502a 100644 --- a/spec/views/layouts/_footer_spec.rb +++ b/spec/views/layouts/_footer_spec.rb @@ -12,7 +12,10 @@ describe 'layouts/_footer.html.haml', :type => "view" do assert_select("a[href=#{'/policy/community'}]", 'Community Guidelines') rendered.should contain 'License' rendered.should contain 'Github' - rendered.should contain 'Wiki' rendered.should contain 'Mailing list' end + + it 'should not have an explicit wiki link' do + rendered.should_not contain 'Wiki' + end end