diff --git a/Gemfile b/Gemfile index 8f18e4b06..feb4a674e 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,9 @@ gem 'debugger' # Markdown formatting for updates etc gem 'bluecloth' +# Pagination +gem 'will_paginate', '~> 3.0' + # user signup/login/etc gem 'devise' diff --git a/Gemfile.lock b/Gemfile.lock index 4d9ab9d62..253687f70 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,7 +49,7 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.6.1) + coffee-script-source (1.6.2) columnize (0.3.6) commonjs (0.2.6) compass (0.12.2) @@ -122,8 +122,8 @@ GEM net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) newrelic_rpm (3.5.8.72) - nokogiri (1.5.6) nokogiri (1.5.7) + nokogiri (1.5.8) orm_adapter (0.4.0) passenger (3.0.19) daemon_controller (>= 1.0.0) @@ -212,6 +212,7 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) + will_paginate (3.0.4) PLATFORMS ruby @@ -254,3 +255,4 @@ DEPENDENCIES unicorn watchr webrat + will_paginate (~> 3.0) diff --git a/app/controllers/crops_controller.rb b/app/controllers/crops_controller.rb index 42d3ef0d7..f0cfe2525 100644 --- a/app/controllers/crops_controller.rb +++ b/app/controllers/crops_controller.rb @@ -4,7 +4,7 @@ class CropsController < ApplicationController # GET /crops # GET /crops.json def index - @crops = Crop.all + @crops = Crop.paginate(:page => params[:page]) @new_crops = Crop.limit(20).order('created_at desc').all respond_to do |format| diff --git a/app/controllers/gardens_controller.rb b/app/controllers/gardens_controller.rb index edc82cd84..8eb5608a6 100644 --- a/app/controllers/gardens_controller.rb +++ b/app/controllers/gardens_controller.rb @@ -78,7 +78,7 @@ class GardensController < ApplicationController @garden.destroy respond_to do |format| - format.html { redirect_to gardens_url } + format.html { redirect_to @garden.owner, notice: 'Garden was successfully deleted.' } format.json { head :no_content } end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 40a50f161..24225d3f3 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,7 +1,7 @@ class MembersController < ApplicationController load_and_authorize_resource def index - @members = Member.confirmed + @members = Member.confirmed.paginate(:page => params[:page]) respond_to do |format| format.html # index.html.haml diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index f78a476c6..e725be734 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -4,7 +4,7 @@ class PostsController < ApplicationController # GET /posts.json def index - @posts = Post.all + @posts = Post.paginate(:page => params[:page]) @recent_posts = Post.limit(100).order('created_at desc').all respond_to do |format| @@ -29,7 +29,7 @@ class PostsController < ApplicationController # GET /posts/new.json def new @post = Post.new - @forum = Forum.find_by_id(params[:forum_id]) || Forum.new + @forum = Forum.find_by_id(params[:forum_id]) respond_to do |format| format.html # new.html.haml diff --git a/app/controllers/support_controller.rb b/app/controllers/support_controller.rb new file mode 100644 index 000000000..e104ae76d --- /dev/null +++ b/app/controllers/support_controller.rb @@ -0,0 +1,2 @@ +class SupportController < ApplicationController +end diff --git a/app/models/garden.rb b/app/models/garden.rb index 8edbbda0b..d8ed4056d 100644 --- a/app/models/garden.rb +++ b/app/models/garden.rb @@ -4,7 +4,7 @@ class Garden < ActiveRecord::Base attr_accessible :name, :slug, :owner_id, :description belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id' - has_many :plantings, :order => 'created_at DESC' + has_many :plantings, :order => 'created_at DESC', :dependent => :destroy has_many :crops, :through => :plantings default_scope order("lower(name) asc") diff --git a/app/models/member.rb b/app/models/member.rb index 87c3b8915..445533947 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -10,6 +10,7 @@ class Member < ActiveRecord::Base has_and_belongs_to_many :roles has_many :notifications, :foreign_key => 'recipient_id' has_many :sent_notifications, :foreign_key => 'sender_id' + default_scope order("lower(login_name) asc") # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml index 5eb9fc606..5f8472c96 100644 --- a/app/views/comments/_form.html.haml +++ b/app/views/comments/_form.html.haml @@ -11,6 +11,8 @@ .field = f.text_area :body, :rows => 6, :class => 'input-block-level' + %span.help-block + = render :partial => "shared/markdown_help" .actions = f.submit 'Post comment', :class => 'btn' - if defined?(@post) diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml index f9a58e807..9355a4c12 100644 --- a/app/views/crops/index.html.haml +++ b/app/views/crops/index.html.haml @@ -1,8 +1,9 @@ - content_for :title, "Crops" - c = 0 -%p - = "Displaying #{@crops.length} crops" +%div.pagination + = page_entries_info @crops, :model => "crops" + = will_paginate @crops %ul.thumbnails .row diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml index 18689db65..8e10475a1 100644 --- a/app/views/devise/mailer/confirmation_instructions.html.haml +++ b/app/views/devise/mailer/confirmation_instructions.html.haml @@ -1,9 +1,41 @@ +- site_name = Growstuff::Application.config.site_name %p - Welcome - = @resource.email + Welcome, + = @resource.login_name ! -%p You can confirm your account email through the link below: +%p + Your account on #{site_name} has been created. You just need to confirm + your email address through the link below: %p = link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) + +%p + Once you're confirmed, you can sign in with your login name + (#{@resource.login_name}) or email address (#{@resource.email}), + and the password you provided when you signed up. Note that your + login name and password are case sensitive. + +%p + We're excited to have you as a member, and hope you'll enjoy + what #{site_name} has to offer. Take a look around the site, + =link_to 'plant some things', url_for(:controller => '/crops', :only_path => false) + , and feel free to drop in on the + =link_to 'forums', url_for(:controller => '/forums', :only_path => false) + if you have any questions or feedback. + +%p + We'd also appreciate it if you'd read our + =link_to 'Community Guidelines', url_for(:controller => '/policy', :action => 'community', :only_path => false) + , and make sure you follow them. We want #{site_name} to be a + friendly, welcoming environment for everyone, and we hope you'll + help us keep it that way. + +%p + Looking forward to seeing you! + +%p + The #{site_name} team. + %br/ + =link_to root_url, root_url diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 302035063..d5319d492 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -13,19 +13,24 @@ - else = link_to "#{othergarden}", garden_path(othergarden) - - if can? :edit, @garden - = link_to 'Edit', edit_garden_path(@garden), :class => 'btn' - = link_to 'New', new_garden_path, :class => 'btn' + - if can? :create, @garden + = link_to 'New Garden', new_garden_path, :class => 'btn btn-mini' .span9 %div :markdown #{@garden.description} - - if can? :edit, @garden - %p= link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-large btn-primary' + = link_to 'Edit Garden', edit_garden_path(@garden), :class => 'btn btn-mini' + - if can? :destroy, @garden + = link_to 'Delete Garden', @garden, method: :delete, | + data: { confirm: 'All plantings associated with this garden will also be deleted. Are you sure?' }, :class => 'btn btn-mini' + + %h3 + What's planted here? + - if can? :edit, @garden + = link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-primary' - %h3 What's planted here? - @garden.plantings.each do |p| = render :partial => "plantings/thumbnail", :locals => { :planting => p } diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index df20e1416..9ca101d7a 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -7,4 +7,5 @@ %li= link_to "Terms of Service", url_for(:controller => '/policy', :action => 'tos') %li= link_to "Privacy Policy", url_for(:controller => %'/policy', :action => 'privacy') %li= link_to "Community Guidelines", url_for(:controller => '/policy', :action => 'community') + %li= link_to "Support/FAQ", url_for(:controller => '/support') %li= link_to "Open Source", %"https://github.com/Growstuff/growstuff" diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml index ef034d062..aa64bc9c1 100644 --- a/app/views/members/index.html.haml +++ b/app/views/members/index.html.haml @@ -1,7 +1,8 @@ = content_for :title, "#{Growstuff::Application.config.site_name} members" -%p - = "Displaying #{@members.length} members" +%div.pagination + = page_entries_info @members, :model => "members" + = will_paginate @members %ul.thumbnails - @members.each do |m| diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml index d4fe1704a..72f845ea2 100644 --- a/app/views/posts/_form.html.haml +++ b/app/views/posts/_form.html.haml @@ -9,8 +9,13 @@ = label_tag :post, "Subject" = f.text_field :subject, :class => 'input-block-level' - = label_tag :body, "What's going on in your food garden?" + - if @post.forum || @forum + = label_tag :body, "What's up?" + - else + = label_tag :body, "What's going on in your food garden?" = f.text_area :body, :rows => 12, :class => 'input-block-level' + %span.help-block + = render :partial => "shared/markdown_help" - if @post.forum || @forum - forum = @post.forum || @forum diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml index b16bd5d26..846aa00e2 100644 --- a/app/views/posts/index.html.haml +++ b/app/views/posts/index.html.haml @@ -1,8 +1,10 @@ = content_for :title, "Recent #{Growstuff::Application.config.site_name} member posts" -%p= link_to 'Post something', new_post_path, :class => 'btn' +%p= link_to 'Post something', new_post_path, :class => 'btn btn-primary' -%p= "Displaying #{@posts.length} posts" +%div.pagination + = page_entries_info @posts, :model => "posts" + = will_paginate @posts - @posts.each do |post| = render :partial => "single", :locals => { :post => post, :subject => true } diff --git a/app/views/posts/new.html.haml b/app/views/posts/new.html.haml index e1014c41f..e66052ee5 100644 --- a/app/views/posts/new.html.haml +++ b/app/views/posts/new.html.haml @@ -1,4 +1,4 @@ -= content_for :title, @forum.name ? "Post in #{@forum.name}" : "Post something" += content_for :title, @forum ? "Post in #{@forum.name}" : "Post something" =render 'form' diff --git a/app/views/shared/_markdown_help.html.haml b/app/views/shared/_markdown_help.html.haml new file mode 100644 index 000000000..ada576147 --- /dev/null +++ b/app/views/shared/_markdown_help.html.haml @@ -0,0 +1,4 @@ +You can use +=link_to 'Markdown', 'http://daringfireball.net/projects/markdown/syntax/' +to format your text. For instance, *italic*, **bold**, or a link +[like this](http://to.some.site.com/). diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml new file mode 100644 index 000000000..70ead408a --- /dev/null +++ b/app/views/support/index.html.haml @@ -0,0 +1,201 @@ +-content_for :title, 'Support - Frequently Asked Questions' + +:markdown + ## About Growstuff + + ### Who runs Growstuff? + + Growstuff is run by Alex Bayley ([Skud](/members/skud)) and Courtney + Webster ([phazel](/members/phazel)), two software developers from Melbourne, Australia. + + ### How did Growstuff get started? + + The idea of Growstuff came out of a discussion at an open source conference in Spain in 2012. We wanted a free, open source of information about planting and growing crops, and realised the best way to do this would be to crowdsource it from gardeners around the world. + + We first set up Growstuff as an open source project in August 2012, and quietly launched it in March 2013. We are planning to have a full public launch in May 2013. + + ### Is Growstuff a non-profit? + + No, Growstuff is a for-profit business (Growstuff Pty Ltd), incorporated in Australia. The business helps provide hosting and support for the Growstuff website. However, we make our best efforts to operate as an ethical, transparent, and community-minded company. You should also know that software and aggregated data about crops and who's growing them are freely available under open licenses. You might like to read [Why Growstuff is Open Source](http://blog.growstuff.org/2013/02/20/why-growstuff-is-open-source/) to understand some of the reasoning behind that. + + ### How does Growstuff make money? + + We will offer paid subscriptions/memberships, which give you access to special features and a warm glow of knowing you're supporting a sustainable, community-focused project. + + ### Can I advertise on Growstuff? + + Sorry, we're 100% ad-free! + + If you're a member, you can post things to trade or sell in our trading post area, but we don't have and will never have banner ads or the like. We believe that supporting a website through outside advertising makes for a less pleasant experience for our members and visitors, and is not a sustainable business model. + + ### What's the status of Growstuff? Is it in beta? + + As of March 2013, we are using the term "soft launch" for Growstuff's status. What we mean by this is that although we're open for signups, we're still busily working on features and getting everything ready for our larger, more public launch, which will happen in a couple of months' time. You can read more about this in our [blog post about the soft launch](http://blog.growstuff.org/2013/03/21/a-soft-launch/). + + Beyond that, Growstuff will always be in development, and we hope to keep releasing features regularly. You should expect Growstuff to change and grow all the time, just like your garden. If a feature you want isn't available yet, check back soon! + + ## Membership and payments + + ### Can I use Growstuff for free? + + Absolutely! You can sign up right now for a no-cost membership and use it for as long as you want, perhaps forever. + + ### Can I get a membership for my family, school, or community group? + + Yup! Feel free to sign up as "JonesFamily" or "SmithfieldCommunity" or whatever floats your boat. + + Just keep in mind that you are responsible for anything that happens under that account, so be careful who you allow to use it. In due course, we are hoping to develop features to help community gardens share with their members/gardeners, so that they can track what's planted in the community garden without having to login as the community garden account. We'll publicise this widely when it's ready, so keep an ear to the ground. + + ### What other types of accounts are there? + + We will be releasing paid accounts soon, which will give you access to special or "premium" features in thanks for supporting the site's operations with your cash. + + ## Profile, settings, and privacy + + ### How do I add a picture to my profile? + + Profile pictures are provided [Gravatar](http://gravatar.com Gravatar), a service that provides "Globally Recognised Avatars", run by the people who operate the Wordpress blogging platform. + + If you have ever signed up for Gravatar in the past, using the same address as you signed up for Growstuff, you will already have a picture for your profile. + + If you have signed up for Growstuff with a different email address than your Gravatar address, you will need to add it on Gravatar. + + If you have never signed up for Gravatar before, you can create an account and upload a picture, which will appear not only on Growstuff, but on any other site which supports Gravatars and where you use the same email address. + + ### Do I have to fill in all this personal stuff? + + Your profile asks several questions about you, which you can choose to answer (or not) as you see fit. We don't require personal information like your legal name, gender, or age for tracking or demographic purposes -- one of the benefits of not having ads on our site! + + When it comes to location, it really helps if you can provide that to Growstuff because we use it to suggest things to grow. However, you can do it at whatever level of detail you're comfortable with: perhaps the name of your town, or your state or province, or even your country if the country is small enough and has a fairly consistent climate. Just choose something that is close enough to give you accurate growing advice, and vague enough to feel safe. + + You can read more about the privacy of your information in our [Privacy Policy](http://growstuff.org/policy/privacy). + + + ## Crops, gardens, and planting + + ### How can I add a new crop? + + For now, please drop a note in [Requests for new crops](http://www.growstuff.org/posts/skud-20130319-requests-for-new-crops) on our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). + + ### Will you add non-edible plants? + + We do not currently have plans to add plants which are not edible or which are not "useful" in a food-growing or sustainability context -- these might include companions plants, green manure crops, plants used to manage pests or diseases, and the like. If you're thinking of purely ornamental plants, we probably won't be adding them anytime soon. + + However, we are hoping, in future, to support the ability for any member to plant "unofficial" plants that aren't in our crop database. + + ## Posting, commenting, and forums + + ### What formatting can I use in posts and comments? + + We use [Markdown](http://daringfireball.net/projects/markdown/syntax/) syntax, which offers a pretty wide range of options from simple emphasis (bold and italics) to links, pictures, and more. We're hoping to install a toolbar to help you generate the right syntax, but in the meantime I'm afraid all we can offer is the rather technical documentation linked above. + + ## Forthcoming features + + ### Where can I see what features are planned? + + Our software developers use a tracking tool called Pivotal Tracker, and you can see ours at [http://tracker.growstuff.org/](http://tracker.growstuff.org). This tells you what features we are currently working on and plan to work on soon. + + Pivotal Tracker's interface shows three columns of information: + + * the "Current" section shows the features (called "stories") that we're working on at the moment + * "Backlog" shows you stories that we're planning to work on in the nearish future + * "Icebox" contains stories that we've identified as things we'd like to do, but which don't have a timeframe set yet. + + ### Where can I suggest a feature I'd like to see? + + We suggest checking the [tracker](http://tracker.growstuff.org/) first (see above) to see if it's something we're already planning or talking about. Once you've done that, if it's not already planned or you have some other comments to make, you can post your suggestion in the [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support]. + + ## Developers and API + + ### Is there a Growstuff API? + + At present there is no official API, as our site is still changing so rapidly. However, we do expose some of our data via JSON and/or RSS feeds, and you're welcome to play with it, on the understanding that it may change under you. You can find API docs on our wiki, at http://wiki.growstuff.org/index.php/API + + Use of our API and data is subject to the [API and Data Use Policy](http://www.growstuff.org/policy/api). + + ### What license is your data under? + + Growstuff's data is licensed under the [Creative Commons Attribution Share-Alike license (CC-BY-SA) 3.0 Unported license](http://creativecommons.org/licenses/by-sa/3.0/). This means you can re-use it as long as you attribute it to Growstuff (by linking back to our site), and as long as your own app/site/project shares its own content or data under CC-BY-SA. + + See our [API and Data Use Policy](http://growstuff.org/policy/api) for more information. + + ## Volunteering and jobs + + ### Are you hiring? + + Sadly, no. We're a self-funded/bootstrapped company, and at present we're not even paying ourselves. + + When we are ready to hire, we will most likely look first to people we know from our community. If you want to get involved, see below. + + ### How can I volunteer to help Growstuff? + + First and foremost, by being an active member of the site -- growing crops, tracking your harvests, posting in our forums, getting to know other members -- you help build our database and our community, without which Growstuff would be completely pointless. So, thanks for that! + + Secondly, we'd love it if you could spread the word about Growstuff to your friends who grow their own food or who might like to try. You can see some tips on how to do that below. + + Growstuff's software is built with the help of volunteer developers, too. If you're a coder or would like to learn how to code, you can join us in that. All are welcome, regardless of experience. + + We also have volunteer crop wranglers, who manage our crops database, and moderators, who help keep the forums running smoothly. These are usually chosen from among our most active and helpful members. + + ### How can I get involved as a coder? + + Start by checking out our [wiki](http://wiki.growstuff.org/), code on [Github](http://github.com/Growstuff/growstuff), and [tracker](http://tracker.growstuff.org) to get an idea of how we work. + + If you want to get involved, you should join our [discussion mailing list](http://lists.growstuff.org/mailman/listinfo/discuss) and/or come hang out on our [IRC channel](http://wiki.growstuff.org/index.php/IRC), #growstuff on irc.freenode.net. + + ### My coding skills are rusty or non-existent. Can I still get involved? + + Sure! We love to mentor new coders, people who haven't coded in a while, or people who are just learning our platform (Ruby on Rails) for the first time. We work by pair programming, and can get you started on easy stories, starting with something as simple as fixing a typo or HTML tag (check the "easy" tag in our [tracker](http://tracker.growstuff.org) for some examples). + + ### How can I help spread the word about Growstuff? + + First and foremost, by telling your friends and inviting them to join and be part of it. We don't want to be spammy about it, so we'll never ask to scrape your address book or automatically post Facebook updates or tweet on your behalf. But we would really love it if you'd tell people in your own words. + + Places to spread the word online: Facebook, Twitter, and other social media; your own blog or website; gardening or sustainability forums you participate in. + + Or offline: tell friends, family and neighbours; spread the word through your local community gardens, farmers markets, or produce swaps; contact your local sustainability or Transition group; or any other place where you think food-growers might be. + + ## Terms of service, copyright, and other abuse + + ### Where can I report a violation of the Terms of Service or Community Guidelines? + + You can post in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support) or send email to [support@growstuff.org](mailto:support@growstuff.org). + + ### What do you consider spam, and how can I report it? + + There are many kinds of spam. The most obvious is repeated, unwanted commercial advertising. Many spammers also post irrelevant, nonsensical, or low-value content to forums to try and get you to click on a link, or just to see what they can get away with. + + Please report all these kinds of spam! + + For now, because we're so new, we don't have a good spam reporting mechanism set up. However, you can drop a link in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support) and we'll do what we can. + + ### Someone posted something I believe is copyright. Where can I report it? + + If you are the copyright owner, you can submit a complaint by following the procedure outlined in our [Copyright Infringement Policy](http://growstuff.org/policy/copyright). + + ### Is Growstuff safe for kids to use? + + As a website that's focused on growing food, we expect Growstuff to be a pretty safe and friendly environment. However, some parts of the site (such as posts made by members) may contain mature concepts, coarse language, and the like. If you don't want your kids exposed to these, we strongly suggest you supervise their use of Growstuff. We also suggest you be careful about what personal information your kids share on Growstuff. + + ## Further support + + ### Where can I find a list of known issues with the site? + + In the [Known Issues](http://www.growstuff.org/posts/skud-20130319-known-issues) post on our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). + + ### My question's not answered here. Where can I ask for further support? + + On our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). Please check the list of known issues before posting. + + ### Where can I post feedback/kudos? + + We love feedback! Drop us a note in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). (Is there an echo in here?) + + ### How else can I contact you? + + If you need help with something that hasn't been covered here, then you can send an email to [support@growstuff.org](mailto:support@growstuff.org). + + Media/press enquiries can go to [media@growstuff.org](mailto:media@growstuff.org). + + If you have an enquiry about the site in general (eg. businessy stuff, or just want to get in touch with someone official in a non-support-like way), you can send an email to [info@growstuff.org](mailto:info@growstuff.org). + diff --git a/config/environments/development.rb b/config/environments/development.rb index a2b56bfe9..7dd35bd30 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,10 +40,13 @@ Growstuff::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { - :address => "localhost", - :port => 25, - :domain => "growstuff.org" + :port => '587', + :address => 'smtp.mandrillapp.com', + :user_name => ENV['MANDRILL_USERNAME'], + :password => ENV['MANDRILL_APIKEY'], + :authentication => :login } + config.action_mailer.delivery_method = :smtp Growstuff::Application.configure do config.site_name = "Growstuff (dev)" diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index 69cc7892c..fada677b5 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -56,7 +56,7 @@ en: failure: 'Could not authenticate you from %{kind} because "%{reason}".' mailer: confirmation_instructions: - subject: 'Confirmation instructions' + subject: 'Welcome to Growstuff. Please confirm your account.' reset_password_instructions: subject: 'Reset password instructions' unlock_instructions: diff --git a/config/routes.rb b/config/routes.rb index 46596ff7c..413be78f9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,5 +73,7 @@ Growstuff::Application.routes.draw do # match ':controller(/:action(/:id))(.:format)' match '/policy/:action' => 'policy#:action' + match '/support' => 'support#index' + match '/support/:action' => 'support#:action' end diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 569f856f6..d96bc2baf 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -131,7 +131,7 @@ describe GardensController do it "redirects to the gardens list" do garden = Garden.create! valid_attributes delete :destroy, {:id => garden.to_param} - response.should redirect_to(gardens_url) + response.should redirect_to(garden.owner) end end diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 4eb13d9f6..5fe9c1ddd 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -48,7 +48,7 @@ describe PostsController do it "doesn't die if no forum specified" do get :new, {} - assigns(:forum).should be_a_new(Forum) + assigns(:forum).should eq nil end end diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index 2527ea7f9..1523c504b 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -71,4 +71,14 @@ describe Garden do end end + it "destroys plantings when deleted" do + @garden = FactoryGirl.create(:garden, :owner => @owner) + @planting1 = FactoryGirl.create(:planting, :garden => @garden) + @planting2 = FactoryGirl.create(:planting, :garden => @garden) + @garden.plantings.length.should == 2 + all = Planting.count + @garden.destroy + Planting.count.should == all - 2 + end + end diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 34cecc1c9..e8ef4baad 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -123,6 +123,14 @@ describe 'member' do end end + context 'ordering' do + it "should be sorted by name" do + z = FactoryGirl.create(:member, :login_name => "Zoe") + a = FactoryGirl.create(:member, :login_name => "Anna") + Member.first.should == a + end + end + context 'invalid login names' do it "doesn't allow short names" do member = FactoryGirl.build(:invalid_member_shortname) diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index 59fe03d7f..1fe66ef5f 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -14,4 +14,10 @@ describe "comments/new" do assert_select "textarea#comment_body", :name => "comment[body]" end end + + it 'shows markdown help' do + render + rendered.should contain 'Markdown' + end + end diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 1444ae7ff..3735418f4 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -3,10 +3,16 @@ require 'spec_helper' describe "crops/index" do before(:each) do controller.stub(:current_user) { nil } - assign(:crops, [ - FactoryGirl.create(:tomato), - FactoryGirl.create(:maize) - ]) + page = 1 + per_page = 2 + total_entries = 2 + crops = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| + pager.replace([ + FactoryGirl.create(:tomato), + FactoryGirl.create(:maize) + ]) + end + assign(:crops, crops) end it "renders a list of crops" do @@ -15,11 +21,6 @@ describe "crops/index" do assert_select "a", :text => "Tomato" end - it "counts the number of crops" do - render - rendered.should contain "Displaying 2 crops" - end - context "logged in and crop wrangler" do before(:each) do @member = FactoryGirl.create(:crop_wrangling_member) diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index ec50a6635..3a0921ae7 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -11,5 +11,9 @@ describe 'devise/mailer/confirmation_instructions.html.haml', :type => "view" do it 'should have a confirmation link' do rendered.should contain 'Confirm my account' end + + it 'should have a link to the homepage' do + rendered.should contain root_url + end end end diff --git a/spec/views/layouts/_footer_spec.rb b/spec/views/layouts/_footer_spec.rb index b8fadd2da..a746f2e70 100644 --- a/spec/views/layouts/_footer_spec.rb +++ b/spec/views/layouts/_footer_spec.rb @@ -12,6 +12,7 @@ describe 'layouts/_footer.html.haml', :type => "view" do assert_select("a[href=/policy/privacy]", 'Privacy Policy') assert_select("a[href=/policy/community]", 'Community Guidelines') rendered.should contain 'Open Source' + assert_select("a[href=/support]", 'Support/FAQ') end it 'should not have an explicit wiki link' do diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb index b4c33c75e..cc6f9401b 100644 --- a/spec/views/members/index.html.haml_spec.rb +++ b/spec/views/members/index.html.haml_spec.rb @@ -2,17 +2,20 @@ require 'spec_helper' describe "members/index" do before(:each) do - assign(:members, [ - FactoryGirl.create(:member), - FactoryGirl.create(:member) - ]) + controller.stub(:current_user) { nil } + page = 1 + per_page = 2 + total_entries = 2 + members = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| + pager.replace([ + FactoryGirl.create(:member), + FactoryGirl.create(:member) + ]) + end + assign(:members, members) render end - it "counts the number of members" do - rendered.should contain "Displaying 2 members" - end - it "contains two gravatar icons" do assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2 end diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 43b24b006..e95b1285a 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -4,10 +4,16 @@ describe "posts/index" do before(:each) do controller.stub(:current_user) { nil } @author = FactoryGirl.create(:member) - # We use create (= build+save) to generate slugs and hence paths for posts - @post1 = FactoryGirl.create(:post, :author => @author) - @post2 = FactoryGirl.create(:post, :author => @author) - assign(:posts, [@post1, @post2]) + page = 1 + per_page = 2 + total_entries = 2 + posts = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| + pager.replace([ + FactoryGirl.create(:post, :author => @author), + FactoryGirl.create(:post, :author => @author) + ]) + end + assign(:posts, posts) render end @@ -18,10 +24,6 @@ describe "posts/index" do :text => "This is some text.".to_s, :count => 2 end - it "counts the number of posts" do - rendered.should contain "Displaying 2 posts" - end - it "contains two gravatar icons" do assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2 end diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index aa7da6fba..be69c972c 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -4,7 +4,7 @@ describe "posts/new" do before(:each) do @author = FactoryGirl.create(:member) assign(:post, FactoryGirl.create(:post, :author => @author)) - assign(:forum, Forum.new) +# assign(:forum, Forum.new) sign_in @author controller.stub(:current_user) { @author } end @@ -18,13 +18,20 @@ describe "posts/new" do end it 'no hidden forum field' do + render assert_select "input#post_forum_id[type=hidden]", false end it 'no forum mentioned' do + render rendered.should_not contain "This post will be posted in the forum" end + it "asks what's going on in your garden" do + render + rendered.should contain "What's going on in your food garden?" + end + context "forum specified" do before(:each) do @forum = assign(:forum, FactoryGirl.create(:forum)) @@ -39,6 +46,17 @@ describe "posts/new" do it 'tells the user what forum it will be posted in' do rendered.should contain "This post will be posted in the forum #{@forum.name}" end + + it "asks what's going on generally" do + render + rendered.should_not contain "What's going on in your food garden?" + rendered.should contain "What's up?" + end + end + + it 'shows markdown help' do + render + rendered.should contain 'Markdown' end end diff --git a/spec/views/support/index_spec.rb b/spec/views/support/index_spec.rb new file mode 100644 index 000000000..7945ff5d3 --- /dev/null +++ b/spec/views/support/index_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'support/index.html.haml', :type => "view" do + before(:each) do + render + end + + it 'should show support faq' do + render + rendered.should contain 'About Growstuff' + end +end