mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7eb5e0014 | ||
|
|
f08d02f4c5 | ||
|
|
6ed7376c58 | ||
|
|
c8a200bf19 | ||
|
|
a62b668781 | ||
|
|
09f82d5995 | ||
|
|
8d0bec34a6 | ||
|
|
d7ec4eacee | ||
|
|
3a3f4eefbf | ||
|
|
9e00023332 | ||
|
|
3058160a59 | ||
|
|
e3886ce5b5 | ||
|
|
48f8085e2d | ||
|
|
594e466fd4 | ||
|
|
b813669d71 | ||
|
|
d0b8ae3411 | ||
|
|
9c993e9f47 | ||
|
|
d5fece87d0 | ||
|
|
33816d4312 | ||
|
|
00e6aeed5c | ||
|
|
0205b345d0 | ||
|
|
9f8a32e9f8 | ||
|
|
7357524271 | ||
|
|
6aa689b0d8 | ||
|
|
962b3b574d | ||
|
|
d77d1d9a77 | ||
|
|
4bed6da422 | ||
|
|
023c870d49 | ||
|
|
9aff65e956 | ||
|
|
0446c0a405 | ||
|
|
7719d1f896 | ||
|
|
c9558e4d51 | ||
|
|
8a679670e4 | ||
|
|
a7586e9d2b | ||
|
|
811011419e | ||
|
|
dae3ea2789 | ||
|
|
49aa6bb846 | ||
|
|
c154a9b845 | ||
|
|
ad14ecb41b | ||
|
|
08a73ce503 | ||
|
|
6663f3ade4 | ||
|
|
451030761d | ||
|
|
d4e4ca6519 | ||
|
|
284f0cddcd | ||
|
|
4ced7ee7e9 | ||
|
|
b60510e016 | ||
|
|
e85daa405b | ||
|
|
9ab83f7bbc | ||
|
|
329e0106bb | ||
|
|
4743fc7a63 | ||
|
|
c66a5b12a5 | ||
|
|
f98bb32612 | ||
|
|
771443ee85 | ||
|
|
1322ebd8e3 | ||
|
|
9e98db423e | ||
|
|
305702f644 | ||
|
|
1f4f806bb0 | ||
|
|
6a17ba547f | ||
|
|
3ffdc61428 | ||
|
|
bb6e9e32e6 | ||
|
|
229396d9e7 | ||
|
|
0fa02272b0 | ||
|
|
a91b8605c4 | ||
|
|
f1107b518c | ||
|
|
52d93a7ccd | ||
|
|
d3df1e8f33 | ||
|
|
eb77715b70 | ||
|
|
252910694d | ||
|
|
bd063be3a9 | ||
|
|
9a6d827b6d | ||
|
|
ede5187369 | ||
|
|
610a5b7a48 | ||
|
|
1fa71c1546 | ||
|
|
7574eb554e | ||
|
|
eea7e19ecf | ||
|
|
dafaffcd73 | ||
|
|
3e149a5d1d | ||
|
|
c20d9b78c5 | ||
|
|
7906d50d13 | ||
|
|
faed8b019e | ||
|
|
c8974a869f | ||
|
|
3969f410f1 | ||
|
|
6304f230a5 | ||
|
|
73524b8883 | ||
|
|
fd9fc38def | ||
|
|
949c7c31d8 | ||
|
|
e34dcd03bc | ||
|
|
d8bf8ae4df | ||
|
|
83fea92353 | ||
|
|
1317ce9db0 | ||
|
|
e489831241 | ||
|
|
3d4f5c6917 |
8
Gemfile
8
Gemfile
@@ -32,8 +32,11 @@ gem 'cancancan' # for checking member privileges
|
||||
gem 'csv_shaper' # CSV export
|
||||
gem 'figaro' # for handling config via ENV variables
|
||||
gem 'gibbon', '~>1.2.0' # for Mailchimp newsletter subscriptions
|
||||
gem 'leaflet-markercluster-rails'
|
||||
gem 'leaflet-rails', '~> 0.7.7' # Newer versions break tests - see https://travis-ci.org/CloCkWeRX/growstuff/builds/200984350
|
||||
|
||||
# Maps
|
||||
gem 'leaflet-rails'
|
||||
gem 'rails-assets-leaflet.markercluster', source: 'https://rails-assets.org'
|
||||
|
||||
gem 'pg'
|
||||
gem 'ruby-units' # for unit conversion
|
||||
gem 'unicorn' # http server
|
||||
@@ -131,6 +134,7 @@ group :development, :test do
|
||||
gem 'coveralls', require: false # coverage analysis
|
||||
gem 'database_cleaner'
|
||||
gem 'factory_bot_rails' # for creating test data
|
||||
gem 'faker'
|
||||
gem 'haml-i18n-extractor'
|
||||
gem 'haml-rails' # HTML templating language
|
||||
gem 'haml_lint' # Checks haml files for goodness
|
||||
|
||||
43
Gemfile.lock
43
Gemfile.lock
@@ -1,5 +1,6 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
actionmailer (4.2.10)
|
||||
actionpack (= 4.2.10)
|
||||
@@ -84,8 +85,8 @@ GEM
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.10.0)
|
||||
byebug (9.1.0)
|
||||
cancancan (2.1.1)
|
||||
capybara (2.16.0)
|
||||
cancancan (2.1.2)
|
||||
capybara (2.16.1)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (>= 1.3.3)
|
||||
@@ -180,6 +181,8 @@ GEM
|
||||
factory_bot_rails (4.8.2)
|
||||
factory_bot (~> 4.8.2)
|
||||
railties (>= 3.0.0)
|
||||
faker (1.8.4)
|
||||
i18n (~> 0.5)
|
||||
faraday (0.12.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.18)
|
||||
@@ -191,7 +194,7 @@ GEM
|
||||
formatador (0.2.5)
|
||||
friendly_id (5.2.3)
|
||||
activerecord (>= 4.0.0)
|
||||
geocoder (1.4.4)
|
||||
geocoder (1.4.5)
|
||||
gibbon (1.2.1)
|
||||
httparty
|
||||
multi_json (>= 1.9.0)
|
||||
@@ -241,7 +244,7 @@ GEM
|
||||
excon
|
||||
moneta
|
||||
multi_json (>= 1.9.2)
|
||||
highline (1.7.8)
|
||||
highline (1.7.10)
|
||||
html2haml (2.2.0)
|
||||
erubis (~> 2.7.0)
|
||||
haml (>= 4.0, < 6)
|
||||
@@ -273,7 +276,7 @@ GEM
|
||||
thor (>= 0.14, < 2.0)
|
||||
jquery-ui-rails (5.0.5)
|
||||
railties (>= 3.2.16)
|
||||
js-routes (1.4.1)
|
||||
js-routes (1.4.2)
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (2.1.0)
|
||||
@@ -295,12 +298,11 @@ GEM
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-core (1.1.1)
|
||||
kgio (2.11.0)
|
||||
kramdown (1.15.0)
|
||||
kramdown (1.16.2)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
leaflet-markercluster-rails (0.7.0)
|
||||
railties (>= 3.1)
|
||||
leaflet-rails (0.7.7)
|
||||
leaflet-rails (1.2.0)
|
||||
rails (>= 4.2.0)
|
||||
letter_opener (1.4.1)
|
||||
launchy (~> 2.2)
|
||||
listen (3.1.5)
|
||||
@@ -400,6 +402,9 @@ GEM
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.10)
|
||||
sprockets-rails
|
||||
rails-assets-leaflet (1.2.0)
|
||||
rails-assets-leaflet.markercluster (1.2.0)
|
||||
rails-assets-leaflet (>= 1.0.3)
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.8)
|
||||
@@ -423,7 +428,7 @@ GEM
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rainbow (2.1.0)
|
||||
raindrops (0.19.0)
|
||||
rake (12.2.1)
|
||||
rake (12.3.0)
|
||||
rb-fsevent (0.10.2)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
@@ -447,7 +452,7 @@ GEM
|
||||
rspec-mocks (3.7.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.7.0)
|
||||
rspec-rails (3.7.1)
|
||||
rspec-rails (3.7.2)
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
@@ -479,7 +484,7 @@ GEM
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
selenium-webdriver (3.7.0)
|
||||
selenium-webdriver (3.8.0)
|
||||
childprocess (~> 0.5)
|
||||
rubyzip (~> 1.0)
|
||||
sexp_processor (4.10.0)
|
||||
@@ -494,8 +499,8 @@ GEM
|
||||
json (>= 1.8, < 3)
|
||||
simplecov-html (~> 0.10.0)
|
||||
simplecov-html (0.10.2)
|
||||
sparkpost_rails (1.4.0)
|
||||
rails (>= 4.0, < 5.1)
|
||||
sparkpost_rails (1.5.0)
|
||||
rails (>= 4.0, < 5.2)
|
||||
sprockets (3.7.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
@@ -514,7 +519,7 @@ GEM
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
timecop (0.9.1)
|
||||
tins (1.15.1)
|
||||
tins (1.16.0)
|
||||
trollop (1.16.2)
|
||||
tzinfo (1.2.4)
|
||||
thread_safe (~> 0.1)
|
||||
@@ -575,6 +580,7 @@ DEPENDENCIES
|
||||
elasticsearch-model
|
||||
elasticsearch-rails
|
||||
factory_bot_rails
|
||||
faker
|
||||
figaro
|
||||
flickraw
|
||||
font-awesome-sass
|
||||
@@ -596,8 +602,7 @@ DEPENDENCIES
|
||||
js-routes
|
||||
jsonapi-resources
|
||||
kaminari
|
||||
leaflet-markercluster-rails
|
||||
leaflet-rails (~> 0.7.7)
|
||||
leaflet-rails
|
||||
letter_opener
|
||||
memcachier
|
||||
newrelic_rpm
|
||||
@@ -611,6 +616,7 @@ DEPENDENCIES
|
||||
pry
|
||||
quiet_assets
|
||||
rails (~> 4.2.8)
|
||||
rails-assets-leaflet.markercluster!
|
||||
rails_12factor
|
||||
rainbow (< 2.2.0)
|
||||
rake (>= 10.0.0)
|
||||
@@ -630,8 +636,9 @@ DEPENDENCIES
|
||||
will_paginate
|
||||
xmlrpc
|
||||
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
BUNDLED WITH
|
||||
1.15.4
|
||||
1.16.0
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
@import 'bootstrap-datepicker'
|
||||
@import 'leaflet'
|
||||
@import 'leaflet.markercluster'
|
||||
@import 'leaflet.markercluster.default'
|
||||
@import 'custom_bootstrap/custom_bootstrap'
|
||||
@import 'overrides'
|
||||
@import 'graphs'
|
||||
|
||||
@@ -5,7 +5,7 @@ class AccountTypesController < ApplicationController
|
||||
|
||||
# GET /account_types
|
||||
def index
|
||||
@account_types = AccountType.all
|
||||
@account_types = AccountType.all.order(:name)
|
||||
respond_with(@account_types)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class AccountsController < ApplicationController
|
||||
|
||||
# GET /accounts
|
||||
def index
|
||||
@accounts = Account.all
|
||||
@accounts = Account.all.order(created_at: :desc)
|
||||
respond_with(@accounts)
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class AlternateNamesController < ApplicationController
|
||||
# GET /alternate_names
|
||||
# GET /alternate_names.json
|
||||
def index
|
||||
@alternate_names = AlternateName.all
|
||||
@alternate_names = AlternateName.all.order(:name)
|
||||
respond_with(@alternate_names)
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class CommentsController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@comments = Comment.paginate(page: params[:page])
|
||||
@comments = Comment.order(created_at: :desc).paginate(page: params[:page])
|
||||
respond_with(@comments)
|
||||
end
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class CropsController < ApplicationController
|
||||
def crops
|
||||
q = Crop.approved.includes(:scientific_names, plantings: :photos)
|
||||
q = q.popular unless @sort == 'alpha'
|
||||
q.includes(:photos).paginate(page: params[:page])
|
||||
q.order("LOWER(crops.name)").includes(:photos).paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def requested_crops
|
||||
|
||||
@@ -5,7 +5,7 @@ class ForumsController < ApplicationController
|
||||
# GET /forums
|
||||
# GET /forums.json
|
||||
def index
|
||||
@forums = Forum.all
|
||||
@forums = Forum.all.order(:name)
|
||||
respond_with(@forums)
|
||||
end
|
||||
|
||||
|
||||
@@ -68,6 +68,6 @@ class GardensController < ApplicationController
|
||||
def gardens
|
||||
g = @owner ? @owner.gardens : Garden.all
|
||||
g = g.active unless @show_all
|
||||
g.joins(:owner).order(:updated_at).paginate(page: params[:page])
|
||||
g.joins(:owner).order(:name).paginate(page: params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,8 +96,10 @@ class MembersController < ApplicationController
|
||||
end
|
||||
|
||||
def members
|
||||
q = Member.confirmed
|
||||
q = q.recently_joined if @sort == 'recently_joined'
|
||||
q.paginate(page: params[:page])
|
||||
if @sort == 'recently_joined'
|
||||
Member.recently_joined
|
||||
else
|
||||
Member.order(:login_name)
|
||||
end.confirmed.paginate(page: params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ class NotificationsController < ApplicationController
|
||||
|
||||
# GET /notifications
|
||||
def index
|
||||
@notifications = Notification.by_recipient(current_member).page(params[:page])
|
||||
@notifications = Notification.by_recipient(current_member).order(:created_at).page(params[:page])
|
||||
end
|
||||
|
||||
# GET /notifications/1
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
class OrderItemsController < ApplicationController
|
||||
before_action :authenticate_member!
|
||||
load_and_authorize_resource
|
||||
respond_to :html
|
||||
responders :flash
|
||||
|
||||
# POST /order_items
|
||||
def create
|
||||
if params[:order_item][:price]
|
||||
params[:order_item][:price] = params[:order_item][:price].to_f * 100 # convert to cents
|
||||
end
|
||||
|
||||
@order_item = OrderItem.new(order_item_params)
|
||||
@order_item.order = current_member.current_order || Order.create(member_id: current_member.id)
|
||||
|
||||
respond_to do |format|
|
||||
if @order_item.save
|
||||
format.html { redirect_to @order_item.order, notice: 'Added item to your order.' }
|
||||
else
|
||||
errors = @order_item.errors.empty? ?
|
||||
"There was a problem with your order." : @order_item.errors.full_messages.to_sentence
|
||||
format.html { redirect_to shop_path, alert: errors }
|
||||
end
|
||||
if @order_item.save
|
||||
redirect_to @order_item.order, notice: 'Added item to your order.'
|
||||
else
|
||||
redirect_to shop_path, alert: errors
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def errors
|
||||
if @order_item.errors.empty?
|
||||
"There was a problem with your order."
|
||||
else
|
||||
@order_item.errors.full_messages.to_sentence
|
||||
end
|
||||
end
|
||||
|
||||
def order_item_params
|
||||
params.require(:order_item).permit(:order_id, :price, :product_id, :quantity)
|
||||
end
|
||||
|
||||
@@ -12,15 +12,17 @@ class PhotosController < ApplicationController
|
||||
else
|
||||
@photos = Photo.all
|
||||
end
|
||||
@photos = @photos.includes(:owner).order(:created_at).paginate(page: params[:page])
|
||||
@photos = @photos.order(created_at: :desc)
|
||||
.includes(:owner)
|
||||
.paginate(page: params[:page])
|
||||
respond_with(@photos)
|
||||
end
|
||||
|
||||
def new
|
||||
@type = params[:type]
|
||||
@id = params[:id]
|
||||
|
||||
@photo = Photo.new
|
||||
@item = item_to_link_to
|
||||
@type = item_type
|
||||
@id = item_id
|
||||
retrieve_from_flickr
|
||||
respond_with @photo
|
||||
end
|
||||
@@ -30,9 +32,13 @@ class PhotosController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
find_or_create_photo_from_flickr_photo
|
||||
add_photo_to_collection
|
||||
@photo.save if @photo.present?
|
||||
ActiveRecord::Base.transaction do
|
||||
@photo = find_or_create_photo_from_flickr_photo
|
||||
@item = item_to_link_to
|
||||
raise "Could not find this #{type} owned by you" unless @item
|
||||
collection << @item unless collection.include?(@item)
|
||||
@photo.save! if @photo.present?
|
||||
end
|
||||
respond_with @photo
|
||||
end
|
||||
|
||||
@@ -48,8 +54,14 @@ class PhotosController < ApplicationController
|
||||
|
||||
private
|
||||
|
||||
def item_id?
|
||||
params.key? :id
|
||||
#
|
||||
# Params
|
||||
def item_id
|
||||
params[:id]
|
||||
end
|
||||
|
||||
def item_type
|
||||
params[:type]
|
||||
end
|
||||
|
||||
def flickr_photo_id_param
|
||||
@@ -61,26 +73,32 @@ class PhotosController < ApplicationController
|
||||
:license_url, :thumbnail_url, :fullsize_url, :link_url)
|
||||
end
|
||||
|
||||
def find_or_create_photo_from_flickr_photo
|
||||
@photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param)
|
||||
@photo = Photo.new(photo_params) unless @photo
|
||||
@photo.owner_id = current_member.id
|
||||
@photo.set_flickr_metadata
|
||||
@photo
|
||||
# Item with photos attached
|
||||
#
|
||||
def item_to_link_to
|
||||
raise "No item id provided" if item_id.nil?
|
||||
raise "No item type provided" if item_type.nil?
|
||||
raise "Missing or invalid type provided" unless photos_supported_on_type?(item_type)
|
||||
item_class = Growstuff::Constants::PhotoModels.get_item(item_type)
|
||||
item_class.find_by!(id: params[:id], owner_id: current_member.id)
|
||||
end
|
||||
|
||||
def add_photo_to_collection
|
||||
raise "Missing or invalid type provided" unless Growstuff::Constants::PhotoModels.types.include?(params[:type])
|
||||
raise "No item id provided" unless item_id?
|
||||
collection = Growstuff::Constants::PhotoModels.get_relation(@photo, params[:type])
|
||||
def collection
|
||||
Growstuff::Constants::PhotoModels.get_relation(@photo, item_type)
|
||||
end
|
||||
|
||||
item_class = Growstuff::Constants::PhotoModels.get_item(params[:type])
|
||||
item = item_class.find_by!(id: params[:id], owner_id: current_member.id)
|
||||
raise "Could not find this item owned by you" unless item
|
||||
def photos_supported_on_type?(_type)
|
||||
Growstuff::Constants::PhotoModels.types.include?(item_type)
|
||||
end
|
||||
|
||||
collection << item unless collection.include?(item)
|
||||
rescue => e
|
||||
flash[:alert] = e.message
|
||||
#
|
||||
# Flickr retrieval
|
||||
def find_or_create_photo_from_flickr_photo
|
||||
photo = Photo.find_by(flickr_photo_id: flickr_photo_id_param)
|
||||
photo ||= Photo.new(photo_params)
|
||||
photo.owner_id = current_member.id
|
||||
photo.set_flickr_metadata
|
||||
photo
|
||||
end
|
||||
|
||||
def retrieve_from_flickr
|
||||
|
||||
@@ -4,7 +4,7 @@ class PlantPartsController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@plant_parts = PlantPart.all
|
||||
@plant_parts = PlantPart.all.order(:name)
|
||||
respond_with(@plant_parts)
|
||||
end
|
||||
|
||||
|
||||
@@ -96,8 +96,8 @@ class PlantingsController < ApplicationController
|
||||
end
|
||||
p = p.current unless @show_all
|
||||
p.joins(:owner, :crop, :garden)
|
||||
.order(created_at: :desc)
|
||||
.includes(:crop, :owner, :garden)
|
||||
.order(:created_at)
|
||||
.paginate(page: params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,6 +66,6 @@ class PostsController < ApplicationController
|
||||
@author.posts
|
||||
else
|
||||
Post
|
||||
end.includes(:author, comments: :author).paginate(page: params[:page])
|
||||
end.order(created_at: :desc).includes(:author, comments: :author).paginate(page: params[:page])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class ProductsController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@products = Product.all
|
||||
@products = Product.all.order(:name)
|
||||
respond_with @products
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class RolesController < ApplicationController
|
||||
responders :flash
|
||||
|
||||
def index
|
||||
@roles = Role.all
|
||||
@roles = Role.all.order(:name)
|
||||
respond_with @roles
|
||||
end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class ScientificNamesController < ApplicationController
|
||||
# GET /scientific_names
|
||||
# GET /scientific_names.json
|
||||
def index
|
||||
@scientific_names = ScientificName.all
|
||||
@scientific_names = ScientificName.all.order(:name)
|
||||
respond_with(@scientific_names)
|
||||
end
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class SeedsController < ApplicationController
|
||||
crop.seeds
|
||||
else
|
||||
Seed
|
||||
end.includes(:owner, :crop).paginate(page: params[:page])
|
||||
end.order(created_at: :desc).includes(:owner, :crop).paginate(page: params[:page])
|
||||
end
|
||||
|
||||
def csv_filename
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
class AccountType < ActiveRecord::Base
|
||||
#
|
||||
# Relationships
|
||||
has_many :products
|
||||
|
||||
#
|
||||
# Validations
|
||||
validates :name, presence: true, uniqueness: true
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
@@ -2,7 +2,6 @@ class Comment < ActiveRecord::Base
|
||||
belongs_to :author, class_name: 'Member'
|
||||
belongs_to :post
|
||||
|
||||
default_scope { order("created_at DESC") }
|
||||
scope :post_order, -> { reorder("created_at ASC") } # for display on post page
|
||||
|
||||
after_create do
|
||||
|
||||
@@ -24,8 +24,7 @@ class Crop < ActiveRecord::Base
|
||||
|
||||
##
|
||||
## Scopes
|
||||
default_scope { order("lower(crops.name) asc") }
|
||||
scope :recent, -> { approved.reorder("created_at desc") }
|
||||
scope :recent, -> { approved.order(created_at: :desc) }
|
||||
scope :toplevel, -> { approved.where(parent_id: nil) }
|
||||
scope :popular, -> { approved.reorder("plantings_count desc, lower(name) asc") }
|
||||
# ok on sqlite and psql, but not on mysql
|
||||
|
||||
@@ -14,7 +14,7 @@ class Garden < ActiveRecord::Base
|
||||
after_validation :empty_unwanted_geocodes
|
||||
after_save :mark_inactive_garden_plantings_as_finished
|
||||
|
||||
default_scope { joins(:owner).order("lower(name) asc") }
|
||||
default_scope { joins(:owner) } # Ensures owner exists
|
||||
scope :active, -> { where(active: true) }
|
||||
scope :inactive, -> { where(active: false) }
|
||||
|
||||
@@ -62,7 +62,7 @@ class Garden < ActiveRecord::Base
|
||||
unique_plantings = []
|
||||
seen_crops = []
|
||||
|
||||
plantings.includes(:garden, :crop, :owner, :harvests).each do |p|
|
||||
plantings.order(created_at: :desc).includes(:garden, :crop, :owner, :harvests).each do |p|
|
||||
unless seen_crops.include?(p.crop)
|
||||
unique_plantings.push(p)
|
||||
seen_crops.push(p.crop)
|
||||
@@ -88,6 +88,6 @@ class Garden < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def default_photo
|
||||
photos.first
|
||||
photos.order(created_at: :desc).first
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class Harvest < ActiveRecord::Base
|
||||
|
||||
##
|
||||
## Scopes
|
||||
default_scope { joins(:owner) }
|
||||
default_scope { joins(:owner) } # Ensures owner exists
|
||||
|
||||
##
|
||||
## Validations
|
||||
@@ -124,9 +124,11 @@ class Harvest < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def default_photo
|
||||
photos.first || crop.default_photo
|
||||
photos.order(created_at: :desc).first || crop.default_photo
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def crop_must_match_planting
|
||||
return if planting.blank? # only check if we are linked to a planting
|
||||
errors.add(:planting, "must be the same crop") unless crop == planting.crop
|
||||
|
||||
@@ -6,48 +6,40 @@ class Member < ActiveRecord::Base
|
||||
|
||||
friendly_id :login_name, use: %i(slugged finders)
|
||||
|
||||
#
|
||||
# Relationshops
|
||||
has_many :posts, foreign_key: 'author_id'
|
||||
has_many :comments, foreign_key: 'author_id'
|
||||
has_many :forums, foreign_key: 'owner_id'
|
||||
has_many :gardens, foreign_key: 'owner_id'
|
||||
has_many :plantings, foreign_key: 'owner_id'
|
||||
|
||||
has_many :seeds, foreign_key: 'owner_id'
|
||||
has_many :harvests, foreign_key: 'owner_id'
|
||||
|
||||
has_and_belongs_to_many :roles # rubocop:disable Rails/HasAndBelongsToMany
|
||||
|
||||
has_many :notifications, foreign_key: 'recipient_id'
|
||||
has_many :sent_notifications, foreign_key: 'sender_id'
|
||||
|
||||
has_many :authentications
|
||||
|
||||
has_many :orders
|
||||
has_one :account
|
||||
has_one :account_type, through: :account
|
||||
|
||||
has_many :photos
|
||||
|
||||
has_many :requested_crops, class_name: Crop, foreign_key: 'requester_id'
|
||||
has_many :likes, dependent: :destroy
|
||||
has_many :follows, class_name: "Follow", foreign_key: "follower_id", dependent: :destroy
|
||||
has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id", dependent: :destroy
|
||||
has_many :followed, through: :follows
|
||||
has_many :followers, through: :inverse_follows, source: :follower
|
||||
|
||||
default_scope { order("lower(login_name) asc") }
|
||||
|
||||
#
|
||||
# Scopes
|
||||
scope :confirmed, -> { where.not(confirmed_at: nil) }
|
||||
scope :located, -> { where.not(location: '').where.not(latitude: nil).where.not(longitude: nil) }
|
||||
scope :recently_signed_in, -> { reorder(updated_at: :desc) }
|
||||
scope :recently_joined, -> { reorder(confirmed_at: :desc) }
|
||||
scope :wants_newsletter, -> { where(newsletter: true) }
|
||||
scope :interesting, -> { confirmed.located.recently_signed_in.has_plantings }
|
||||
|
||||
scope :has_plantings, -> { joins(:plantings).group("members.id") }
|
||||
|
||||
has_many :follows, class_name: "Follow", foreign_key: "follower_id"
|
||||
has_many :followed, through: :follows
|
||||
|
||||
has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id"
|
||||
has_many :followers, through: :inverse_follows, source: :follower
|
||||
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
@@ -57,45 +49,42 @@ class Member < ActiveRecord::Base
|
||||
|
||||
# set up geocoding
|
||||
geocoded_by :location
|
||||
after_validation :geocode
|
||||
after_validation :empty_unwanted_geocodes
|
||||
|
||||
# Virtual attribute for authenticating by either username or email
|
||||
# This is in addition to a real persisted field like 'username'
|
||||
attr_accessor :login
|
||||
|
||||
#
|
||||
# Validations
|
||||
# Requires acceptance of the Terms of Service
|
||||
validates :tos_agreement, acceptance: { allow_nil: true,
|
||||
accept: true }
|
||||
|
||||
validates :tos_agreement, acceptance: { allow_nil: true, accept: true }
|
||||
validates :login_name,
|
||||
length: {
|
||||
minimum: 2,
|
||||
maximum: 25,
|
||||
message: "should be between 2 and 25 characters long"
|
||||
minimum: 2, maximum: 25, message: "should be between 2 and 25 characters long"
|
||||
},
|
||||
exclusion: {
|
||||
in: %w(growstuff admin moderator staff nearby),
|
||||
message: "name is reserved"
|
||||
in: %w(growstuff admin moderator staff nearby), message: "name is reserved"
|
||||
},
|
||||
format: {
|
||||
with: /\A\w+\z/,
|
||||
message: "may only include letters, numbers, or underscores"
|
||||
with: /\A\w+\z/, message: "may only include letters, numbers, or underscores"
|
||||
},
|
||||
uniqueness: {
|
||||
case_sensitive: false
|
||||
}
|
||||
|
||||
# Give each new member a default garden
|
||||
after_create { |member| Garden.create(name: "Garden", owner_id: member.id) }
|
||||
#
|
||||
# Triggers
|
||||
after_validation :geocode
|
||||
after_validation :empty_unwanted_geocodes
|
||||
after_save :update_newsletter_subscription
|
||||
|
||||
# Give each new member a default garden
|
||||
# and an account record (for paid accounts etc)
|
||||
# we use find_or_create to avoid accidentally creating a second one,
|
||||
# which can happen sometimes especially with FactoryBot associations
|
||||
after_create { |member| Garden.create(name: "Garden", owner_id: member.id) }
|
||||
after_create { |member| Account.find_or_create_by(member_id: member.id) }
|
||||
|
||||
after_save :update_newsletter_subscription
|
||||
|
||||
# allow login via either login_name or email address
|
||||
def self.find_first_by_auth_conditions(warden_conditions)
|
||||
conditions = warden_conditions.dup
|
||||
|
||||
@@ -5,7 +5,6 @@ class Notification < ActiveRecord::Base
|
||||
|
||||
validates :subject, length: { maximum: 255 }
|
||||
|
||||
default_scope { order('created_at DESC') }
|
||||
scope :unread, -> { where(read: false) }
|
||||
scope :by_recipient, ->(recipient) { where(recipient_id: recipient) }
|
||||
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
class Order < ActiveRecord::Base
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :member, with_deleted: true
|
||||
|
||||
has_many :order_items, dependent: :destroy
|
||||
|
||||
default_scope { order('created_at DESC') }
|
||||
|
||||
#
|
||||
# Validations
|
||||
validates :referral_code, format: {
|
||||
with: /\A[a-zA-Z0-9 ]*\z/,
|
||||
message: "may only include letters and numbers"
|
||||
}
|
||||
|
||||
#
|
||||
# Teiggers
|
||||
before_save :standardize_referral_code
|
||||
|
||||
#
|
||||
# Scopes
|
||||
scope :by_member, ->(member) { where(member: member) }
|
||||
|
||||
# total price of an order
|
||||
|
||||
@@ -8,7 +8,7 @@ class Photo < ActiveRecord::Base
|
||||
|
||||
before_destroy { all_associations.clear }
|
||||
|
||||
default_scope { joins(:owner).order(created_at: :desc) }
|
||||
default_scope { joins(:owner) } # Ensures the owner still exists
|
||||
|
||||
def associations?
|
||||
plantings.any? || harvests.any? || gardens.any? || seeds.any?
|
||||
|
||||
@@ -22,7 +22,7 @@ class Planting < ActiveRecord::Base
|
||||
|
||||
##
|
||||
## Scopes
|
||||
default_scope { joins(:owner).order(created_at: :desc) }
|
||||
default_scope { joins(:owner) } # Ensures the owner still exists
|
||||
scope :finished, -> { where(finished: true) }
|
||||
scope :current, -> { where(finished: false) }
|
||||
scope :interesting, -> { has_photos.one_per_owner }
|
||||
@@ -72,7 +72,7 @@ class Planting < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def default_photo
|
||||
photos.first
|
||||
photos.order(created_at: :desc).first
|
||||
end
|
||||
|
||||
def planted?
|
||||
|
||||
@@ -2,45 +2,27 @@ class Post < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
include Likeable
|
||||
friendly_id :author_date_subject, use: %i(slugged finders)
|
||||
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :author, class_name: 'Member'
|
||||
belongs_to :forum
|
||||
has_many :comments, dependent: :destroy
|
||||
has_and_belongs_to_many :crops # rubocop:disable Rails/HasAndBelongsToMany
|
||||
before_destroy { |post| post.crops.clear }
|
||||
after_save :update_crops_posts_association
|
||||
# also has_many notifications, but kinda meaningless to get at them
|
||||
# from this direction, so we won't set up an association for now.
|
||||
|
||||
after_create do
|
||||
recipients = []
|
||||
sender = author.id
|
||||
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |_m|
|
||||
# find member case-insensitively and add to list of recipients
|
||||
member = Member.case_insensitive_login_name(Regexp.last_match(1)).first
|
||||
recipients << member if member && !recipients.include?(member)
|
||||
end
|
||||
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_AT_REGEX) do |_m|
|
||||
# find member case-insensitively and add to list of recipients
|
||||
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..-1]).first
|
||||
recipients << member if member && !recipients.include?(member)
|
||||
end
|
||||
# don't send notifications to yourself
|
||||
recipients.map(&:id).each do |recipient|
|
||||
next unless recipient != sender
|
||||
Notification.create(
|
||||
recipient_id: recipient,
|
||||
sender_id: sender,
|
||||
subject: "#{author} mentioned you in their post #{subject}",
|
||||
body: body
|
||||
)
|
||||
end
|
||||
end
|
||||
#
|
||||
# Triggers
|
||||
before_destroy { |post| post.crops.clear }
|
||||
after_save :update_crops_posts_association
|
||||
after_create :send_notification
|
||||
|
||||
default_scope { joins(:author).order(created_at: :desc) }
|
||||
default_scope { joins(:author) } # Ensures the owner still exists
|
||||
|
||||
validates :subject,
|
||||
presence: true,
|
||||
length: { maximum: 255 }
|
||||
#
|
||||
# Validations
|
||||
validates :subject, presence: true, length: { maximum: 255 }
|
||||
|
||||
def author_date_subject
|
||||
# slugs are created before created_at is set
|
||||
@@ -56,7 +38,7 @@ class Post < ActiveRecord::Base
|
||||
# i.e. the time of the most recent comment, or of the post itself if
|
||||
# there are no comments.
|
||||
def recent_activity
|
||||
comments.present? ? comments.reorder('created_at DESC').first.created_at : created_at
|
||||
comments.present? ? comments.order(created_at: :desc).first.created_at : created_at
|
||||
end
|
||||
|
||||
# return posts sorted by recent activity
|
||||
@@ -78,4 +60,29 @@ class Post < ActiveRecord::Base
|
||||
crops << crop if crop && !crops.include?(crop)
|
||||
end
|
||||
end
|
||||
|
||||
def send_notification
|
||||
recipients = []
|
||||
sender = author.id
|
||||
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |_m|
|
||||
# find member case-insensitively and add to list of recipients
|
||||
member = Member.case_insensitive_login_name(Regexp.last_match(1)).first
|
||||
recipients << member if member && !recipients.include?(member)
|
||||
end
|
||||
body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_AT_REGEX) do |_m|
|
||||
# find member case-insensitively and add to list of recipients
|
||||
member = Member.case_insensitive_login_name(Regexp.last_match(1)[1..-1]).first
|
||||
recipients << member if member && !recipients.include?(member)
|
||||
end
|
||||
# don't send notifications to yourself
|
||||
recipients.map(&:id).each do |recipient_id|
|
||||
next unless recipient_id != sender
|
||||
Notification.create(
|
||||
recipient_id: recipient_id,
|
||||
sender_id: sender,
|
||||
subject: "#{author} mentioned you in their post #{subject}",
|
||||
body: body
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
class Product < ActiveRecord::Base
|
||||
has_and_belongs_to_many :orders # rubocop:disable Rails/HasAndBelongsToMany
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :account_type
|
||||
has_and_belongs_to_many :orders # rubocop:disable Rails/HasAndBelongsToMany
|
||||
|
||||
validates :paid_months,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 0
|
||||
},
|
||||
allow_nil: true
|
||||
#
|
||||
# Validations
|
||||
validates :paid_months, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates :min_price, presence: true
|
||||
|
||||
def to_s
|
||||
|
||||
@@ -3,81 +3,50 @@ class Seed < ActiveRecord::Base
|
||||
include PhotoCapable
|
||||
friendly_id :seed_slug, use: [:slugged, :finders]
|
||||
|
||||
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze
|
||||
ORGANIC_VALUES = ['certified organic', 'non-certified organic', 'conventional/non-organic', 'unknown'].freeze
|
||||
GMO_VALUES = ['certified GMO-free', 'non-certified GMO-free', 'GMO', 'unknown'].freeze
|
||||
HEIRLOOM_VALUES = %w(heirloom hybrid unknown).freeze
|
||||
|
||||
#
|
||||
# Relationships
|
||||
belongs_to :crop
|
||||
belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id', counter_cache: true
|
||||
|
||||
default_scope { joins(:owner).order(created_at: :desc) }
|
||||
|
||||
#
|
||||
# Validations
|
||||
validates :crop, approved: true
|
||||
delegate :name, to: :crop
|
||||
delegate :default_photo, to: :crop
|
||||
|
||||
validates :crop, presence: { message: "must be present and exist in our database" }
|
||||
validates :quantity,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 0
|
||||
},
|
||||
allow_nil: true
|
||||
validates :days_until_maturity_min,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 0
|
||||
},
|
||||
allow_nil: true
|
||||
validates :days_until_maturity_max,
|
||||
numericality: {
|
||||
only_integer: true,
|
||||
greater_than_or_equal_to: 0
|
||||
},
|
||||
allow_nil: true
|
||||
validates :quantity, allow_nil: true,
|
||||
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates :days_until_maturity_min, allow_nil: true,
|
||||
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates :days_until_maturity_max, allow_nil: true,
|
||||
numericality: { only_integer: true, greater_than_or_equal_to: 0 }
|
||||
validates :tradable_to, allow_nil: false, allow_blank: false,
|
||||
inclusion: { in: TRADABLE_TO_VALUES, message: "You may only trade seed nowhere, "\
|
||||
"locally, nationally, or internationally" }
|
||||
validates :organic, allow_nil: false, allow_blank: false,
|
||||
inclusion: { in: ORGANIC_VALUES, message: "You must say whether the seeds "\
|
||||
"are organic or not, or that you don't know" }
|
||||
validates :gmo, allow_nil: false, allow_blank: false,
|
||||
inclusion: { in: GMO_VALUES, message: "You must say whether the seeds are "\
|
||||
"genetically modified or not, or that you don't know" }
|
||||
validates :heirloom, allow_nil: false, allow_blank: false,
|
||||
inclusion: { in: HEIRLOOM_VALUES, message: "You must say whether the seeds"\
|
||||
"are heirloom, hybrid, or unknown" }
|
||||
|
||||
#
|
||||
# Scopes
|
||||
default_scope { joins(:owner) } # Ensure owner exists
|
||||
scope :tradable, -> { where.not(tradable_to: 'nowhere') }
|
||||
scope :interesting, -> { tradable.has_location }
|
||||
scope :has_location, -> { joins(:owner).where.not("members.location": nil) }
|
||||
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally).freeze
|
||||
validates :tradable_to, inclusion: { in: TRADABLE_TO_VALUES,
|
||||
message: "You may only trade seed nowhere, "\
|
||||
"locally, nationally, or internationally" },
|
||||
allow_nil: false,
|
||||
allow_blank: false
|
||||
|
||||
ORGANIC_VALUES = [
|
||||
'certified organic',
|
||||
'non-certified organic',
|
||||
'conventional/non-organic',
|
||||
'unknown'
|
||||
].freeze
|
||||
validates :organic, inclusion: { in: ORGANIC_VALUES,
|
||||
message: "You must say whether the seeds "\
|
||||
"are organic or not, or that you don't know" },
|
||||
allow_nil: false,
|
||||
allow_blank: false
|
||||
|
||||
GMO_VALUES = [
|
||||
'certified GMO-free',
|
||||
'non-certified GMO-free',
|
||||
'GMO',
|
||||
'unknown'
|
||||
].freeze
|
||||
validates :gmo, inclusion: { in: GMO_VALUES,
|
||||
message: "You must say whether the seeds are "\
|
||||
"genetically modified or not, or that you don't know" },
|
||||
allow_nil: false,
|
||||
allow_blank: false
|
||||
|
||||
HEIRLOOM_VALUES = %w(heirloom hybrid unknown).freeze
|
||||
validates :heirloom, inclusion: { in: HEIRLOOM_VALUES,
|
||||
message: "You must say whether the seeds are heirloom, hybrid, or unknown" },
|
||||
allow_nil: false,
|
||||
allow_blank: false
|
||||
|
||||
def tradable?
|
||||
if tradable_to == 'nowhere'
|
||||
false
|
||||
else
|
||||
true
|
||||
end
|
||||
tradable_to != 'nowhere'
|
||||
end
|
||||
|
||||
def seed_slug
|
||||
|
||||
@@ -21,3 +21,8 @@
|
||||
class: 'btn btn-default', id: 'delete_garden_link' do
|
||||
%span.glyphicon.glyphicon-trash{ title: "Delete" }
|
||||
Delete
|
||||
- if can?(:edit, garden) && can?(:create, Photo)
|
||||
= link_to new_photo_path(type: "garden", id: garden.id),
|
||||
class: 'btn btn-primary' do
|
||||
%span.glyphicon.glyphicon-camera{ title: "Add Photo" }
|
||||
Add Photo
|
||||
|
||||
@@ -91,8 +91,8 @@
|
||||
%p
|
||||
= link_to new_photo_path(type: "garden", id: @garden.id),
|
||||
class: 'btn btn-primary' do
|
||||
%span.glyphicon.glyphicon-camera{ title: "Add Photo" }
|
||||
Add Photo
|
||||
%span.glyphicon.glyphicon-camera{ title: "Add photo" }
|
||||
Add photo
|
||||
- if @garden.photos.size.positive?
|
||||
%h3= localize_plural(@garden.photos, Photo)
|
||||
.row
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
- content_for :title, "New Photo"
|
||||
|
||||
%h3
|
||||
Choose photo for
|
||||
= @item
|
||||
|
||||
- if @flickr_auth
|
||||
%p
|
||||
Connected to Flickr as
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
- if plant_part.crops.empty?
|
||||
No crops are harvested for this plant part (yet).
|
||||
- else
|
||||
!= plant_part.crops.map { |c| link_to(c, c) }.join(", ")
|
||||
- plant_part.crops.limit(100).each do |crop|
|
||||
= link_to(crop, crop_path(crop))
|
||||
%p
|
||||
= link_to "More detail", plant_part
|
||||
|
||||
@@ -18,6 +19,3 @@
|
||||
= link_to 'Edit', edit_plant_part_path(plant_part), class: 'btn btn-default btn-xs'
|
||||
- if can? :destroy, plant_part
|
||||
= link_to 'Delete', plant_part, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
- if can?(:edit, planting) || can?(:destroy, planting)
|
||||
- if can? :edit, planting
|
||||
= link_to edit_planting_path(planting), class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit garden" }
|
||||
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
|
||||
Edit
|
||||
- if can? :destroy, planting
|
||||
= link_to planting, method: :delete,
|
||||
data: { confirm: 'Are you sure?' },
|
||||
class: 'btn btn-default btn-xs' do
|
||||
data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-trash{ title: "Delete" }
|
||||
Delete
|
||||
|
||||
- unless planting.finished
|
||||
= link_to "Mark as finished", planting_path(planting, planting: { finished: 1 }),
|
||||
method: :put, class: 'btn btn-default btn-xs append-date'
|
||||
- if can? :create, Harvest
|
||||
= link_to 'Harvest', new_planting_harvest_path(planting), class: 'btn btn-default btn-xs'
|
||||
= link_to planting_path(planting, planting: { finished: 1 }),
|
||||
method: :put, class: 'btn btn-default btn-xs append-date' do
|
||||
|
||||
%span.glyphicon.glyphicon-ok{ title: "Finished" }
|
||||
Mark as finished
|
||||
|
||||
- if can?(:create, Harvest)
|
||||
= link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-leaf{ title: "Harvest" }
|
||||
Harvest
|
||||
|
||||
- if can?(:edit, planting) && can?(:create, Photo)
|
||||
= link_to new_photo_path(id: planting.id, type: 'planting'), class: 'btn btn-default btn-xs' do
|
||||
%span.glyphicon.glyphicon-camera{ title: "Add photo" }
|
||||
Add photo
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -v
|
||||
|
||||
if [ "$(phantomjs --version)" != '2.1.1' ]; then
|
||||
PHANTOM_URL="https://assets.membergetmember.co/software/phantomjs-2.1.1-linux-x86_64.tar.bz2"
|
||||
rm -rf "$PWD/travis_phantomjs"
|
||||
mkdir -p "$PWD/travis_phantomjs"
|
||||
wget "$PHANTOM_URL" -O "$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2"
|
||||
tar -xvf "$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs"
|
||||
cd "$PWD/travis_phantomjs" || exit 1
|
||||
wget "$PHANTOM_URL"
|
||||
tar -vjxf phantomjs-2.1.1-linux-x86_64.tar.bz2
|
||||
fi
|
||||
|
||||
phantomjs --version
|
||||
which phantomjs
|
||||
phantomjs --version
|
||||
|
||||
@@ -1,22 +1,30 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountTypesController do
|
||||
# This automatically creates a "Free" account type
|
||||
login_member(:admin_member)
|
||||
subject { response }
|
||||
|
||||
def valid_attributes
|
||||
{ "name" => "MyString" }
|
||||
context 'anon' do
|
||||
describe '#index' do
|
||||
before { get :index }
|
||||
it { is_expected.not_to be_success }
|
||||
end
|
||||
end
|
||||
context 'member' do
|
||||
login_member(:member)
|
||||
describe '#index' do
|
||||
before { get :index }
|
||||
it { is_expected.not_to be_success }
|
||||
end
|
||||
end
|
||||
context 'admin' do
|
||||
login_member(:admin_member)
|
||||
describe '#index' do
|
||||
let!(:aaa) { FactoryBot.create :account_type, name: 'aaa' }
|
||||
let!(:zzz) { FactoryBot.create :account_type, name: 'zzz' }
|
||||
before { get :index }
|
||||
it { is_expected.to be_success }
|
||||
it { expect(assigns[:account_types].first).to eql(aaa) }
|
||||
it { expect(assigns[:account_types].last).to eql(zzz) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AccountsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Admin::OrdersController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AdminController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe AuthenticationsController do
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe CommentsController do
|
||||
subject { response }
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
before(:each) do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
controller.stub(:current_member) { @member }
|
||||
sign_in member
|
||||
controller.stub(:current_member) { member }
|
||||
end
|
||||
|
||||
def valid_attributes
|
||||
@@ -25,11 +14,14 @@ describe CommentsController do
|
||||
end
|
||||
|
||||
describe "GET RSS feed" do
|
||||
it "returns an RSS feed" do
|
||||
get :index, format: "rss"
|
||||
response.should be_success
|
||||
response.should render_template("comments/index")
|
||||
response.content_type.should eq("application/rss+xml")
|
||||
let!(:first_comment) { FactoryBot.create :comment, created_at: 10.days.ago }
|
||||
let!(:last_comment) { FactoryBot.create :comment, created_at: 4.minutes.ago }
|
||||
describe "returns an RSS feed" do
|
||||
before { get :index, format: "rss" }
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to render_template("comments/index") }
|
||||
it { expect(response.content_type).to eq("application/rss+xml") }
|
||||
it { expect(assigns(:comments)).to eq([last_comment, first_comment]) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,10 +52,10 @@ describe CommentsController do
|
||||
before { get :edit, id: comment.to_param }
|
||||
|
||||
describe "my comment" do
|
||||
let!(:comment) { FactoryBot.create :comment, author: @member, post: post }
|
||||
let!(:comment) { FactoryBot.create :comment, author: member, post: post }
|
||||
let!(:old_comment) { FactoryBot.create(:comment, post: post, created_at: Time.zone.yesterday) }
|
||||
it "assigns previous comments as @comments" do
|
||||
assigns(:comments).should eq([comment, old_comment])
|
||||
expect(assigns(:comments)).to eq([comment, old_comment])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +69,7 @@ describe CommentsController do
|
||||
before { put :update, id: comment.to_param, comment: valid_attributes }
|
||||
|
||||
describe "my comment" do
|
||||
let(:comment) { FactoryBot.create :comment, author: @member }
|
||||
let(:comment) { FactoryBot.create :comment, author: member }
|
||||
it "redirects to the comment's post" do
|
||||
expect(response).to redirect_to(comment.post)
|
||||
end
|
||||
@@ -90,7 +82,7 @@ describe CommentsController do
|
||||
let(:post) { FactoryBot.create :post, subject: 'our post' }
|
||||
let(:other_post) { FactoryBot.create :post, subject: 'the other post' }
|
||||
let(:valid_attributes) { { post_id: other_post.id, body: "kōrero" } }
|
||||
let(:comment) { FactoryBot.create :comment, author: @member, post: post }
|
||||
let(:comment) { FactoryBot.create :comment, author: member, post: post }
|
||||
it "does not change post_id" do
|
||||
comment.reload
|
||||
expect(comment.post_id).to eq(post.id)
|
||||
@@ -102,7 +94,7 @@ describe CommentsController do
|
||||
before { delete :destroy, id: comment.to_param }
|
||||
|
||||
describe "my comment" do
|
||||
let(:comment) { FactoryBot.create :comment, author: @member }
|
||||
let(:comment) { FactoryBot.create :comment, author: member }
|
||||
it "redirects to the post the comment was on" do
|
||||
expect(response).to redirect_to(comment.post)
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe CropsController do
|
||||
@@ -23,37 +11,39 @@ describe CropsController do
|
||||
}
|
||||
end
|
||||
|
||||
subject { response }
|
||||
|
||||
describe "GET crop wrangler homepage" do
|
||||
it 'fetches the crop wrangler homepage' do
|
||||
get :wrangle
|
||||
response.should be_success
|
||||
response.should render_template("crops/wrangle")
|
||||
expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers)
|
||||
describe 'fetches the crop wrangler homepage' do
|
||||
before { get :wrangle }
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to render_template("crops/wrangle") }
|
||||
it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET crop hierarchy " do
|
||||
it 'fetches the crop hierarchy page' do
|
||||
get :hierarchy
|
||||
response.should be_success
|
||||
response.should render_template("crops/hierarchy")
|
||||
describe 'fetches the crop hierarchy page' do
|
||||
before { get :hierarchy }
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to render_template("crops/hierarchy") }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET crop search" do
|
||||
it 'fetches the crop search page' do
|
||||
get :search
|
||||
response.should be_success
|
||||
response.should render_template("crops/search")
|
||||
describe 'fetches the crop search page' do
|
||||
before { get :search }
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to render_template("crops/search") }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET RSS feed" do
|
||||
it "returns an RSS feed" do
|
||||
get :index, format: "rss"
|
||||
response.should be_success
|
||||
response.should render_template("crops/index")
|
||||
response.content_type.should eq("application/rss+xml")
|
||||
describe "returns an RSS feed" do
|
||||
before { get :index, format: "rss" }
|
||||
it { is_expected.to be_success }
|
||||
it { is_expected.to render_template("crops/index") }
|
||||
it { expect(response.content_type).to eq("application/rss+xml") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ForumsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe GardensController, type: :controller do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe HarvestsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe HomeController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe MembersController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe NotificationsController do
|
||||
|
||||
@@ -1,67 +1,50 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe OrderItemsController do
|
||||
login_member(:admin_member)
|
||||
|
||||
before(:each) do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
@product = FactoryBot.create(:product)
|
||||
@order = FactoryBot.create(:order, member: @member)
|
||||
@order_item = FactoryBot.create(:order_item,
|
||||
order: @order,
|
||||
product: @product,
|
||||
price: @product.min_price)
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
let(:product) { FactoryBot.create(:product) }
|
||||
let(:order) { FactoryBot.create(:order, member: member) }
|
||||
let(:order_item) do
|
||||
FactoryBot.create(:order_item,
|
||||
order: order,
|
||||
product: product,
|
||||
price: product.min_price)
|
||||
end
|
||||
|
||||
describe "POST create" do
|
||||
it "redirects to order" do
|
||||
@order = FactoryBot.create(:order, member: @member)
|
||||
post :create, order_item: {
|
||||
order_id: @order.id,
|
||||
product_id: @product.id,
|
||||
price: @product.min_price
|
||||
}
|
||||
response.should redirect_to(OrderItem.last.order)
|
||||
end
|
||||
context 'signed in' do
|
||||
before { sign_in member }
|
||||
|
||||
it 'creates an order for you' do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
@product = FactoryBot.create(:product)
|
||||
expect {
|
||||
post :create, order_item: {
|
||||
product_id: @product.id,
|
||||
price: @product.min_price
|
||||
}
|
||||
}.to change(Order, :count).by(1)
|
||||
OrderItem.last.order.should be_an_instance_of Order
|
||||
end
|
||||
describe "POST create" do
|
||||
describe "redirects to order" do
|
||||
before do
|
||||
post :create, order_item: { order_id: order.id, product_id: product.id, price: product.min_price }
|
||||
end
|
||||
it { expect(response).to redirect_to(OrderItem.last.order) }
|
||||
it { expect(OrderItem.last.order).to be_an_instance_of Order }
|
||||
end
|
||||
|
||||
describe "with non-int price" do
|
||||
it "converts 3.33 to 333 cents" do
|
||||
@order = FactoryBot.create(:order, member: @member)
|
||||
@product = FactoryBot.create(:product, min_price: 1)
|
||||
expect {
|
||||
post :create, order_item: {
|
||||
order_id: @order.id,
|
||||
product_id: @product.id,
|
||||
price: 3.33
|
||||
}
|
||||
}.to change(OrderItem, :count).by(1)
|
||||
OrderItem.last.price.should eq 333
|
||||
describe 'creates an order for you' do
|
||||
it do
|
||||
expect do
|
||||
post :create, order_item: {
|
||||
product_id: product.id,
|
||||
price: product.min_price
|
||||
}
|
||||
end.to change(Order, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "with non-int price" do
|
||||
it "converts 3.33 to 333 cents" do
|
||||
order = FactoryBot.create(:order, member: member)
|
||||
product = FactoryBot.create(:product, min_price: 1)
|
||||
expect do
|
||||
post :create, order_item: { order_id: order.id, product_id: product.id, price: 3.33 }
|
||||
end.to change(OrderItem, :count).by(1)
|
||||
OrderItem.last.price.should eq 333
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe OrdersController do
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
@@ -34,45 +23,38 @@ describe PhotosController do
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
let(:tomato) { FactoryBot.create(:tomato) }
|
||||
let(:planting) { FactoryBot.create(:planting, crop: tomato, owner: member) }
|
||||
let(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
let(:harvest) { FactoryBot.create(:harvest, owner: member) }
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
let!(:auth) { FactoryBot.create(:flickr_authentication, member: member) }
|
||||
|
||||
before(:each) do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
@member.stub(:flickr_photos) { [[], 0] }
|
||||
@member.stub(:flickr_sets) { { "foo" => "bar" } }
|
||||
controller.stub(:current_member) { @member }
|
||||
sign_in member
|
||||
member.stub(:flickr_photos) { [[], 0] }
|
||||
member.stub(:flickr_sets) { { "foo" => "bar" } }
|
||||
controller.stub(:current_member) { member }
|
||||
end
|
||||
|
||||
it "assigns the flickr auth as @flickr_auth" do
|
||||
@auth = FactoryBot.create(:flickr_authentication, member: @member)
|
||||
get :new, {}
|
||||
assigns(:flickr_auth).should be_an_instance_of(Authentication)
|
||||
describe "planting photos" do
|
||||
before(:each) { get :new, type: "planting", id: planting.id }
|
||||
it { assigns(:flickr_auth).should be_an_instance_of(Authentication) }
|
||||
it { assigns(:item).should eq planting }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
end
|
||||
|
||||
it "assigns a planting id" do
|
||||
get :new, type: "planting", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "planting"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
describe "harvest photos" do
|
||||
before { get :new, type: "harvest", id: harvest.id }
|
||||
it { assigns(:item).should eq harvest }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
end
|
||||
|
||||
it "assigns a harvest id" do
|
||||
get :new, type: "harvest", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "harvest"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
it "assigns a garden id" do
|
||||
get :new, type: "garden", id: 5
|
||||
assigns(:id).should eq "5"
|
||||
assigns(:type).should eq "garden"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
end
|
||||
|
||||
it "assigns the current set as @current_set" do
|
||||
get :new, set: 'foo'
|
||||
assigns(:current_set).should eq "foo"
|
||||
expect(flash[:alert]).not_to be_present
|
||||
describe "garden photos" do
|
||||
before { get :new, type: "garden", id: garden.id }
|
||||
it { assigns(:item).should eq garden }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -99,11 +81,13 @@ describe PhotosController do
|
||||
Photo.last.plantings.first.should eq planting
|
||||
end
|
||||
|
||||
it "doesn't attach a photo to a planting twice" do
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
expect(flash[:alert]).not_to be_present
|
||||
Photo.last.plantings.size.should eq 1
|
||||
describe "doesn't attach a photo to a planting twice" do
|
||||
before do
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: planting.id
|
||||
end
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
it { expect(Photo.last.plantings.size).to eq 1 }
|
||||
end
|
||||
|
||||
it "attaches the photo to a harvest" do
|
||||
@@ -121,18 +105,20 @@ describe PhotosController do
|
||||
|
||||
it "doesn't attach photo to a comment" do
|
||||
comment = FactoryBot.create(:comment)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id
|
||||
expect(flash[:alert]).to be_present
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "comment", id: comment.id
|
||||
end.to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "for the second time" do
|
||||
let(:planting) { FactoryBot.create :planting, owner: member }
|
||||
it "does not add a photo twice" do
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: 1 }
|
||||
post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting'
|
||||
end.to change(Photo, :count).by(1)
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: 1 }
|
||||
post :create, photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting'
|
||||
end.to change(Photo, :count).by(0)
|
||||
end
|
||||
end
|
||||
@@ -159,16 +145,18 @@ describe PhotosController do
|
||||
it "does not create the planting/photo link" do
|
||||
# members will be auto-created, and different
|
||||
another_planting = FactoryBot.create(:planting)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id
|
||||
expect(flash[:alert]).to be_present
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "planting", id: another_planting.id
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
Photo.last.plantings.first.should_not eq another_planting
|
||||
end
|
||||
|
||||
it "does not create the harvest/photo link" do
|
||||
# members will be auto-created, and different
|
||||
another_harvest = FactoryBot.create(:harvest)
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id
|
||||
expect(flash[:alert]).to be_present
|
||||
expect do
|
||||
post :create, photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: another_harvest.id
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
Photo.last.harvests.first.should_not eq another_harvest
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PlacesController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PlantPartsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PlantingsController do
|
||||
@@ -23,85 +11,83 @@ describe PlantingsController do
|
||||
end
|
||||
|
||||
describe "GET index" do
|
||||
before do
|
||||
@member1 = FactoryBot.create(:member)
|
||||
@member2 = FactoryBot.create(:member)
|
||||
@tomato = FactoryBot.create(:tomato)
|
||||
@maize = FactoryBot.create(:maize)
|
||||
@planting1 = FactoryBot.create(:planting, crop: @tomato, owner: @member1)
|
||||
@planting2 = FactoryBot.create(:planting, crop: @maize, owner: @member2)
|
||||
let!(:member1) { FactoryBot.create(:member) }
|
||||
let!(:member2) { FactoryBot.create(:member) }
|
||||
let!(:tomato) { FactoryBot.create(:tomato) }
|
||||
let!(:maize) { FactoryBot.create(:maize) }
|
||||
let!(:planting1) { FactoryBot.create :planting, crop: tomato, owner: member1, created_at: 1.day.ago }
|
||||
let!(:planting2) { FactoryBot.create :planting, crop: maize, owner: member2, created_at: 5.days.ago }
|
||||
|
||||
describe "assigns all plantings as @plantings" do
|
||||
before { get :index, {} }
|
||||
it { expect(assigns(:plantings)).to match [planting1, planting2] }
|
||||
end
|
||||
|
||||
it "assigns all plantings as @plantings" do
|
||||
get :index, {}
|
||||
assigns(:plantings).should =~ [@planting1, @planting2]
|
||||
describe "picks up owner from params and shows owner's plantings only" do
|
||||
before { get :index, owner: member1.slug }
|
||||
it { expect(assigns(:owner)).to eq member1 }
|
||||
it { expect(assigns(:plantings)).to eq [planting1] }
|
||||
end
|
||||
|
||||
it "picks up owner from params and shows owner's plantings only" do
|
||||
get :index, owner: @member1.slug
|
||||
assigns(:owner).should eq @member1
|
||||
assigns(:plantings).should eq [@planting1]
|
||||
end
|
||||
|
||||
it "picks up crop from params and shows the plantings for the crop only" do
|
||||
get :index, crop: @maize.name
|
||||
assigns(:crop).should eq @maize
|
||||
assigns(:plantings).should eq [@planting2]
|
||||
describe "picks up crop from params and shows the plantings for the crop only" do
|
||||
before { get :index, crop: maize.name }
|
||||
it { expect(assigns(:crop)).to eq maize }
|
||||
it { expect(assigns(:plantings)).to eq [planting2] }
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET new" do
|
||||
it "picks up crop from params" do
|
||||
crop = FactoryBot.create(:crop)
|
||||
get :new, crop_id: crop.id
|
||||
assigns(:crop).should eq(crop)
|
||||
describe "picks up crop from params" do
|
||||
let(:crop) { FactoryBot.create(:crop) }
|
||||
before { get :new, crop_id: crop.id }
|
||||
it { expect(assigns(:crop)).to eq(crop) }
|
||||
end
|
||||
|
||||
it "doesn't die if no crop specified" do
|
||||
get :new, {}
|
||||
assigns(:crop).should be_a_new(Crop)
|
||||
describe "doesn't die if no crop specified" do
|
||||
before { get :new, {} }
|
||||
it { expect(assigns(:crop)).to be_a_new(Crop) }
|
||||
end
|
||||
|
||||
it "picks up member's garden from params" do
|
||||
garden = FactoryBot.create(:garden, owner: member)
|
||||
get :new, garden_id: garden.id
|
||||
assigns(:garden).should eq(garden)
|
||||
describe "picks up member's garden from params" do
|
||||
let(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
before { get :new, garden_id: garden.id }
|
||||
it { expect(assigns(:garden)).to eq(garden) }
|
||||
end
|
||||
|
||||
it "Doesn't display another member's garden on planting form" do
|
||||
member = FactoryBot.create(:member) # over-riding member from login_member()
|
||||
garden = FactoryBot.create(:garden, owner: member)
|
||||
get :new, garden_id: garden.id
|
||||
assigns(:garden).should_not eq(garden)
|
||||
describe "Doesn't display another member's garden on planting form" do
|
||||
let(:another_member) { FactoryBot.create(:member) } # over-riding member from login_member()
|
||||
let(:garden) { FactoryBot.create(:garden, owner: another_member) }
|
||||
before { get :new, garden_id: garden.id }
|
||||
it { expect(assigns(:garden)).not_to eq(garden) }
|
||||
end
|
||||
|
||||
it "Doesn't display un-approved crops on planting form" do
|
||||
crop = FactoryBot.create(:crop, approval_status: 'pending')
|
||||
FactoryBot.create(:garden, owner: member)
|
||||
get :new, crop_id: crop.id
|
||||
assigns(:crop).should_not eq(crop)
|
||||
describe "Doesn't display un-approved crops on planting form" do
|
||||
let(:crop) { FactoryBot.create(:crop, approval_status: 'pending') }
|
||||
let!(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
before { get :new, crop_id: crop.id }
|
||||
it { expect(assigns(:crop)).not_to eq(crop) }
|
||||
end
|
||||
|
||||
it "Doesn't display rejected crops on planting form" do
|
||||
crop = FactoryBot.create(:crop, approval_status: 'rejected', reason_for_rejection: 'nope')
|
||||
FactoryBot.create(:garden, owner: member)
|
||||
get :new, crop_id: crop.id
|
||||
assigns(:crop).should_not eq(crop)
|
||||
describe "Doesn't display rejected crops on planting form" do
|
||||
let(:crop) { FactoryBot.create(:crop, approval_status: 'rejected', reason_for_rejection: 'nope') }
|
||||
let!(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
before { get :new, crop_id: crop.id }
|
||||
it { expect(assigns(:crop)).not_to eq(crop) }
|
||||
end
|
||||
|
||||
it "doesn't die if no garden specified" do
|
||||
get :new, {}
|
||||
assigns(:garden).should be_a_new(Garden)
|
||||
describe "doesn't die if no garden specified" do
|
||||
before { get :new, {} }
|
||||
it { expect(assigns(:garden)).to be_a_new(Garden) }
|
||||
end
|
||||
|
||||
it "sets the date of the planting to today" do
|
||||
get :new, {}
|
||||
assigns(:planting).planted_at.should == Time.zone.today
|
||||
describe "sets the date of the planting to today" do
|
||||
before { get :new, {} }
|
||||
it { expect(assigns(:planting).planted_at).to eq Time.zone.today }
|
||||
end
|
||||
|
||||
it "sets the owner automatically" do
|
||||
post :create, planting: valid_attributes
|
||||
assigns(:planting).owner.should eq subject.current_member
|
||||
describe "sets the owner automatically" do
|
||||
before { post :create, planting: valid_attributes }
|
||||
it { expect(assigns(:planting).owner).to eq subject.current_member }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe PostsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ProductsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe RegistrationsController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe RolesController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ScientificNamesController do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe SeedsController do
|
||||
|
||||
@@ -1,45 +1,35 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project.
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ShopController do
|
||||
before :each do
|
||||
@product1 = FactoryBot.create(:product)
|
||||
@product2 = FactoryBot.create(:product)
|
||||
end
|
||||
let!(:product1) { FactoryBot.create(:product, name: 'aaa') }
|
||||
let!(:product2) { FactoryBot.create(:product, name: 'zzz') }
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all products as @products" do
|
||||
get :index, {}
|
||||
assigns(:products).should eq([@product1, @product2])
|
||||
end
|
||||
describe 'not logged in' do
|
||||
before { get :index, {} }
|
||||
|
||||
it "assigns a new @order_item to build forms" do
|
||||
get :index, {}
|
||||
assigns(:order_item).should be_an_instance_of OrderItem
|
||||
end
|
||||
describe "assigns all products as @products ordered by name" do
|
||||
it { expect(assigns(:products)).to eq([product1, product2]) }
|
||||
end
|
||||
|
||||
it "assigns @order as nil if the user doesn't have one" do
|
||||
get :index, {}
|
||||
assigns(:order).should be_nil
|
||||
end
|
||||
describe "assigns a new @order_item to build forms" do
|
||||
it { expect(assigns(:order_item)).to be_an_instance_of OrderItem }
|
||||
end
|
||||
|
||||
it "assigns @order as current_order if there is one" do
|
||||
@member = FactoryBot.create(:member)
|
||||
sign_in @member
|
||||
@order = FactoryBot.create(:order, member: @member)
|
||||
get :index, {}
|
||||
assigns(:order).should eq @order
|
||||
describe "assigns @order as nil if the user doesn't have one" do
|
||||
it { expect(assigns(:order)).to be_nil }
|
||||
end
|
||||
end
|
||||
describe 'logged in' do
|
||||
describe "assigns @order as current_order if there is one" do
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
let!(:order) { FactoryBot.create(:order, member: member) }
|
||||
before do
|
||||
sign_in member
|
||||
get :index, {}
|
||||
end
|
||||
it { expect(assigns(:order)).to eq order }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,10 +2,16 @@
|
||||
|
||||
FactoryBot.define do
|
||||
factory :account_type do
|
||||
name "Free"
|
||||
name { Faker::Name.unique.name }
|
||||
is_paid false
|
||||
is_permanent_paid false
|
||||
|
||||
factory :free_account_type do
|
||||
name "Free"
|
||||
is_paid false
|
||||
is_permanent_paid false
|
||||
end
|
||||
|
||||
factory :paid_account_type do
|
||||
name "Paid"
|
||||
is_paid true
|
||||
|
||||
70
spec/features/gardens/gardens_index_spec.rb
Normal file
70
spec/features/gardens/gardens_index_spec.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
require 'rails_helper'
|
||||
require 'custom_matchers'
|
||||
|
||||
feature "Gardens#index", :js do
|
||||
context "Logged in as member" do
|
||||
let(:member) { FactoryBot.create :member }
|
||||
|
||||
background { login_as member }
|
||||
|
||||
context "with 10 gardens" do
|
||||
before do
|
||||
FactoryBot.create_list :garden, 10, owner: member
|
||||
visit gardens_path(member: member)
|
||||
end
|
||||
|
||||
it "displays each of the gardens" do
|
||||
member.gardens.each do |garden|
|
||||
expect(page).to have_text garden.name
|
||||
end
|
||||
end
|
||||
it "links to each garden" do
|
||||
member.gardens.each do |garden|
|
||||
expect(page).to have_link(garden.name, href: garden_path(garden))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with inactive gardens" do
|
||||
let!(:active_garden) { FactoryBot.create :garden, name: "My active garden", owner: member }
|
||||
let!(:inactive_garden) { FactoryBot.create :inactive_garden, name: "retired garden", owner: member }
|
||||
|
||||
before { visit gardens_path(member: member) }
|
||||
|
||||
it "show active garden" do
|
||||
expect(page).to have_text active_garden.name
|
||||
end
|
||||
it "should not show inactive garden" do
|
||||
expect(page).not_to have_text inactive_garden.name
|
||||
end
|
||||
it "links to active garden" do
|
||||
expect(page).to have_link(active_garden.name, href: garden_path(active_garden))
|
||||
end
|
||||
it "does not link to inactive gardens" do
|
||||
expect(page).not_to have_link(inactive_garden.name, href: garden_path(inactive_garden))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with plantings' do
|
||||
let(:maize) { FactoryBot.create(:maize) }
|
||||
let(:tomato) { FactoryBot.create(:tomato) }
|
||||
|
||||
let!(:planting) do
|
||||
FactoryBot.create :planting, owner: member, crop: maize, garden: member.gardens.first
|
||||
end
|
||||
let!(:finished_planting) do
|
||||
FactoryBot.create :finished_planting, owner: member, crop: tomato, garden: member.gardens.first
|
||||
end
|
||||
|
||||
before do
|
||||
visit gardens_path(member: member)
|
||||
end
|
||||
it "shows planting in garden" do
|
||||
expect(page).to have_link(planting.crop.name, href: planting_path(planting))
|
||||
end
|
||||
it "does not show finished planting" do
|
||||
expect(page).not_to have_text(finished_planting.crop.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "Planting a crop", js: true do
|
||||
let!(:garden) { create :garden }
|
||||
# name is aaa to ensure it is ordered first
|
||||
let!(:garden) { create :garden, name: 'aaa' }
|
||||
let!(:planting) { create :planting, garden: garden, owner: garden.owner, planted_at: Date.parse("2013-3-10") }
|
||||
let!(:tomato) { create :tomato }
|
||||
let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato }
|
||||
@@ -58,7 +59,7 @@ feature "Planting a crop", js: true do
|
||||
end
|
||||
|
||||
scenario "button on index to edit garden" do
|
||||
first(".garden-info").click_link("Edit")
|
||||
first(".garden-info").click_link("edit_garden_link")
|
||||
expect(page).to have_content 'Edit garden'
|
||||
end
|
||||
end
|
||||
|
||||
51
spec/features/photos/new_photo_spec.rb
Normal file
51
spec/features/photos/new_photo_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature "new photo page" do
|
||||
let(:photo) { FactoryBot.create :photo }
|
||||
|
||||
context "signed in member" do
|
||||
let(:member) { FactoryBot.create :member }
|
||||
|
||||
background { login_as member }
|
||||
|
||||
context "viewing a planting" do
|
||||
let(:planting) { FactoryBot.create :planting, owner: member }
|
||||
|
||||
scenario "add photo" do
|
||||
visit planting_path(planting)
|
||||
click_link('Add photo', match: :first)
|
||||
expect(page).to have_text planting.crop.name
|
||||
end
|
||||
end
|
||||
|
||||
context "viewing a harvest" do
|
||||
let(:harvest) { FactoryBot.create :harvest, owner: member }
|
||||
|
||||
scenario "add photo" do
|
||||
visit harvest_path(harvest)
|
||||
click_link "Add photo"
|
||||
expect(page).to have_text harvest.crop.name
|
||||
end
|
||||
end
|
||||
|
||||
context "viewing a garden" do
|
||||
let(:garden) { FactoryBot.create :garden, owner: member }
|
||||
|
||||
scenario "add photo" do
|
||||
visit garden_path(garden)
|
||||
click_link "Add photo"
|
||||
expect(page).to have_text garden.name
|
||||
end
|
||||
end
|
||||
|
||||
pending "viewing a seed" do
|
||||
let(:seed) { FactoryBot.create :seed, owner: member }
|
||||
|
||||
scenario "add photo" do
|
||||
visit seed_path(seed)
|
||||
click_link "Add photo"
|
||||
expect(page).to have_text seed.to_s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -13,17 +13,37 @@ feature "signout" do
|
||||
expect(current_path).to eq crops_path
|
||||
end
|
||||
|
||||
scenario "after signout, redirect to signin page if page needs authentication" do
|
||||
models = %w[plantings harvests posts photos gardens seeds]
|
||||
models.each do |model|
|
||||
visit "/#{model}/new"
|
||||
shared_examples "sign-in redirects" do |path|
|
||||
scenario "after signout, redirect to signin page if page needs authentication" do
|
||||
visit path
|
||||
expect(current_path).to eq new_member_session_path
|
||||
expect(page).to have_http_status(200)
|
||||
fill_in 'Login', with: member.login_name
|
||||
fill_in 'Password', with: member.password
|
||||
click_button 'Sign in'
|
||||
expect(current_path).to eq "/#{model}/new"
|
||||
expect(page).to have_http_status(200)
|
||||
expect(current_path).to eq path
|
||||
click_link 'Sign out'
|
||||
expect(page).to have_http_status(200)
|
||||
expect(current_path).to eq new_member_session_path
|
||||
end
|
||||
end
|
||||
|
||||
let(:path) {}
|
||||
describe 'after signout, redirect to signin page if page needs authentication' do
|
||||
include_examples "sign-in redirects", "/plantings/new"
|
||||
include_examples "sign-in redirects", "/harvests/new"
|
||||
include_examples "sign-in redirects", "/posts/new"
|
||||
include_examples "sign-in redirects", "/gardens/new"
|
||||
include_examples "sign-in redirects", "/seeds/new"
|
||||
end
|
||||
|
||||
scenario 'photos' do
|
||||
garden = FactoryBot.create :garden, owner: member
|
||||
visit "/photos/new?id=#{garden.id}&type=garden"
|
||||
expect(current_path).to eq new_member_session_path
|
||||
expect(page).to have_http_status(200)
|
||||
# photos/new needs id&type params,
|
||||
# but these are stripped after signing in
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,10 +49,6 @@ describe Comment do
|
||||
@c2 = FactoryBot.create(:comment, post: @p, author: @m)
|
||||
end
|
||||
|
||||
it 'is in DESC order by default' do
|
||||
Comment.all.should eq [@c2, @c1]
|
||||
end
|
||||
|
||||
it 'has a scope for ASC order for displaying on post page' do
|
||||
Comment.post_order.should eq [@c1, @c2]
|
||||
end
|
||||
|
||||
@@ -39,10 +39,6 @@ describe Crop do
|
||||
@lowercase = FactoryBot.create(:lowercasecrop, created_at: 2.days.ago)
|
||||
end
|
||||
|
||||
it "should be sorted case-insensitively" do
|
||||
Crop.first.should == @lowercase
|
||||
end
|
||||
|
||||
it 'recent scope sorts by creation date' do
|
||||
Crop.recent.first.should == @uppercase
|
||||
end
|
||||
|
||||
@@ -20,10 +20,4 @@ describe Forum do
|
||||
@post2 = FactoryBot.create(:forum_post, forum: forum)
|
||||
forum.posts.size.should == 2
|
||||
end
|
||||
|
||||
it "orders posts in reverse chron order" do
|
||||
@post1 = FactoryBot.create(:forum_post, forum: forum, created_at: 2.days.ago)
|
||||
@post2 = FactoryBot.create(:forum_post, forum: forum, created_at: 1.day.ago)
|
||||
forum.posts.first.should eq @post2
|
||||
end
|
||||
end
|
||||
|
||||
@@ -93,14 +93,6 @@ describe Garden do
|
||||
end
|
||||
end
|
||||
|
||||
context 'ordering' do
|
||||
it "should be sorted alphabetically" do
|
||||
FactoryBot.create(:garden_z)
|
||||
a = FactoryBot.create(:garden_a)
|
||||
Garden.first.should == a
|
||||
end
|
||||
end
|
||||
|
||||
it "destroys plantings when deleted" do
|
||||
garden = FactoryBot.create(:garden, owner: owner)
|
||||
@planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner)
|
||||
|
||||
@@ -140,16 +140,6 @@ describe 'member' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'ordering' do
|
||||
before do
|
||||
FactoryBot.create(:member, login_name: "Zoe")
|
||||
FactoryBot.create(:member, login_name: "Anna")
|
||||
end
|
||||
it "should be sorted by name" do
|
||||
expect(Member.first.login_name).to eq("Anna")
|
||||
end
|
||||
end
|
||||
|
||||
context 'invalid login names' do
|
||||
it "doesn't allow short names" do
|
||||
member = FactoryBot.build(:invalid_member_shortname)
|
||||
|
||||
@@ -20,7 +20,8 @@ describe Notification do
|
||||
@n2 = FactoryBot.create(:notification, read: true)
|
||||
Notification.unread.should eq [notification]
|
||||
@n3 = FactoryBot.create(:notification, read: false)
|
||||
Notification.unread.should eq [@n3, notification]
|
||||
Notification.unread.should include @n3
|
||||
Notification.unread.should include notification
|
||||
end
|
||||
|
||||
it "counts unread" do
|
||||
|
||||
@@ -25,11 +25,6 @@ describe Order do
|
||||
@order.order_items.first.should eq @order_item
|
||||
end
|
||||
|
||||
it 'sorts by created_at DESC' do
|
||||
@order2 = FactoryBot.create(:order)
|
||||
Order.all.should eq [@order2, @order]
|
||||
end
|
||||
|
||||
it 'updates the account details' do
|
||||
@member = FactoryBot.create(:member)
|
||||
@order = FactoryBot.create(:order, member: @member)
|
||||
|
||||
@@ -155,12 +155,6 @@ describe Planting do
|
||||
planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}"
|
||||
end
|
||||
|
||||
it "sorts plantings in descending order of creation" do
|
||||
@planting1 = FactoryBot.create(:planting)
|
||||
@planting2 = FactoryBot.create(:planting)
|
||||
Planting.first.should eq @planting2
|
||||
end
|
||||
|
||||
it "should have a slug" do
|
||||
planting.slug.should match(/^member\d+-springfield-community-garden-tomato$/)
|
||||
end
|
||||
@@ -321,12 +315,14 @@ describe Planting do
|
||||
p.save
|
||||
end
|
||||
|
||||
Planting.interesting.should eq [
|
||||
[
|
||||
@planting4,
|
||||
@planting3,
|
||||
@planting2,
|
||||
@planting1
|
||||
]
|
||||
].each do |p|
|
||||
Planting.interesting.should include p
|
||||
end
|
||||
end
|
||||
|
||||
context "default arguments" do
|
||||
|
||||
@@ -4,18 +4,6 @@ describe Post do
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
it_behaves_like "it is likeable"
|
||||
|
||||
it "should be sorted in reverse order" do
|
||||
FactoryBot.create(:post,
|
||||
subject: 'first entry',
|
||||
author: member,
|
||||
created_at: 2.days.ago)
|
||||
FactoryBot.create(:post,
|
||||
subject: 'second entry',
|
||||
author: member,
|
||||
created_at: 1.day.ago)
|
||||
Post.first.subject.should == "second entry"
|
||||
end
|
||||
|
||||
it "should have a slug" do
|
||||
post = FactoryBot.create(:post, author: member)
|
||||
time = post.created_at
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "account_types/edit" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "account_types/index" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "account_types/new" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "account_types/show" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "accounts/edit" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "accounts/index" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "accounts/new" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "accounts/show" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'admin/index.html.haml', type: "view" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'admin/newsletter.html.haml', type: "view" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'admin/orders/index.html.haml', type: "view" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/edit" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/index" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'comments/index.rss.haml' do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/new" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "comments/show" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/_grown_for" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/_planting_advice" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/_popover" do
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
## DEPRECATION NOTICE: Do not add new tests to this file!
|
||||
##
|
||||
## View and controller tests are deprecated in the Growstuff project
|
||||
## We no longer write new view and controller tests, but instead write
|
||||
## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
|
||||
## These test the full stack, behaving as a browser, and require less complicated setup
|
||||
## to run. Please feel free to delete old view/controller tests as they are reimplemented
|
||||
## in feature tests.
|
||||
##
|
||||
## If you submit a pull request containing new view or controller tests, it will not be
|
||||
## merged.
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "crops/edit" do
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user