mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-27 17:28:26 -04:00
added recent scope for crops
This commit is contained in:
1 parent
382f77e0c2
commit
4bcc408236
3 files changed
+37
-69
No files matched your search
@@ -12,6 +12,7 @@ class Crop < ActiveRecord::Base
|
||||
has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id'
|
||||
|
||||
default_scope order("lower(system_name) asc")
|
||||
scope :recent, reorder("created_at desc")
|
||||
|
||||
validates :en_wikipedia_url,
|
||||
:format => {
|
||||
|
||||
@@ -1,64 +1,24 @@
|
||||
- if member_signed_in?
|
||||
|
||||
%h1= "Welcome, #{current_member.login_name}"
|
||||
|
||||
.row
|
||||
.visible-desktop.visible-tablet
|
||||
.span2
|
||||
= render :partial => "members/avatar", :locals => { :member => current_member }
|
||||
.span6
|
||||
%p
|
||||
%b Your profile:
|
||||
=link_to current_member, current_member
|
||||
= link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini'
|
||||
|
||||
%p
|
||||
%b Your location:
|
||||
= current_member.location ? current_member.location : 'Not set'
|
||||
= link_to "Edit", edit_registration_path(current_member), :class => 'btn btn-mini'
|
||||
|
||||
%ul.inline
|
||||
%li.first
|
||||
%b Your gardens:
|
||||
- current_member.gardens.each do |g|
|
||||
%li= link_to g.name, g
|
||||
- if can? :create, Garden
|
||||
%li
|
||||
= link_to 'Add', new_garden_path, :class => 'btn btn-mini'
|
||||
|
||||
%p
|
||||
%b Your seed stash:
|
||||
= link_to pluralize(current_member.seeds.count, "variety"), seeds_by_owner_path(:owner => current_member.slug)
|
||||
= link_to 'Add', new_seed_path, :class => 'btn btn-mini'
|
||||
|
||||
.span4
|
||||
%p
|
||||
Your account:
|
||||
%strong
|
||||
= current_member.account_type
|
||||
account
|
||||
%br/
|
||||
- if current_member == current_member && !current_member.is_paid?
|
||||
= link_to "Upgrade and Support #{Growstuff::Application.config.site_name}", shop_path, :class => 'btn btn-primary'
|
||||
= render :partial => 'signed_in'
|
||||
|
||||
- else
|
||||
.visible-desktop.visible-tablet
|
||||
.hero-unit
|
||||
= render :partial => 'blurb'
|
||||
.visible-phone
|
||||
|
||||
.row
|
||||
= render :partial => 'blurb'
|
||||
.row
|
||||
.span8
|
||||
= render :partial => 'crops'
|
||||
= render :partial => 'seeds'
|
||||
= render :partial => 'people'
|
||||
|
||||
- if @interesting_members.present?
|
||||
%h2 Some of our members
|
||||
%ul.thumbnails
|
||||
- @interesting_members.each do |m|
|
||||
%li.span2
|
||||
= render :partial => "members/thumbnail", :locals => { :member => m }
|
||||
|
||||
.row
|
||||
.span6
|
||||
%h2 Recent plantings
|
||||
= render :partial => 'shared/recent_plantings'
|
||||
.span6
|
||||
%h2 Recent posts
|
||||
= render :partial => 'shared/recent_posts'
|
||||
.span4
|
||||
%h2 Keep in touch
|
||||
|
||||
%h2 Open Source
|
||||
|
||||
%h2 Open Data and APIs
|
||||
|
||||
%h2 Get Involved
|
||||
|
||||
%h2 Support Growstuff
|
||||
+18
-11
@@ -33,25 +33,32 @@ describe Crop do
|
||||
end
|
||||
|
||||
context 'ordering' do
|
||||
before(:each) do
|
||||
@uppercase = FactoryGirl.create(:uppercasecrop, :created_at => 1.minute.ago)
|
||||
@lowercase = FactoryGirl.create(:lowercasecrop, :created_at => 2.days.ago)
|
||||
end
|
||||
|
||||
it "should be sorted case-insensitively" do
|
||||
uppercase = FactoryGirl.create(:uppercasecrop)
|
||||
lowercase = FactoryGirl.create(:lowercasecrop)
|
||||
Crop.first.should == lowercase
|
||||
Crop.first.should == @lowercase
|
||||
end
|
||||
|
||||
it 'recent scope sorts by creation date' do
|
||||
Crop.recent.first.should == @uppercase
|
||||
end
|
||||
end
|
||||
|
||||
it 'finds a default scientific name' do
|
||||
@c = FactoryGirl.create(:tomato)
|
||||
@c.default_scientific_name.should eq nil
|
||||
@sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @c)
|
||||
@c.default_scientific_name.should eq @sn.scientific_name
|
||||
@crop = FactoryGirl.create(:tomato)
|
||||
@crop.default_scientific_name.should eq nil
|
||||
@sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @crop)
|
||||
@crop.default_scientific_name.should eq @sn.scientific_name
|
||||
end
|
||||
|
||||
it 'counts plantings' do
|
||||
@c = FactoryGirl.create(:tomato)
|
||||
@c.plantings_count.should eq 0
|
||||
FactoryGirl.create(:planting, :crop => @c)
|
||||
@c.plantings_count.should eq 1
|
||||
@crop = FactoryGirl.create(:tomato)
|
||||
@crop.plantings_count.should eq 0
|
||||
FactoryGirl.create(:planting, :crop => @crop)
|
||||
@crop.plantings_count.should eq 1
|
||||
end
|
||||
|
||||
it 'validates en_wikipedia_url' do
|
||||
|
||||
Reference in new issue
Block a user