diff --git a/Gemfile b/Gemfile index 7d3ce2a58..e711de8ca 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,9 @@ gem 'coffee-rails' gem 'haml' gem 'sass-rails' +# API data +gem 'jsonapi-resources' + # CSS framework gem 'bootstrap-sass' gem 'font-awesome-sass' diff --git a/Gemfile.lock b/Gemfile.lock index 6b5611bc7..a7005eefb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -277,6 +277,10 @@ GEM railties (>= 3.2) sprockets-rails json (2.1.0) + jsonapi-resources (0.9.0) + activerecord (>= 4.1) + concurrent-ruby + railties (>= 4.1) jwt (1.5.6) kaminari (1.1.1) activesupport (>= 4.1.0) @@ -420,7 +424,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) @@ -591,6 +595,7 @@ DEPENDENCIES jquery-rails jquery-ui-rails (~> 5.0.2) js-routes + jsonapi-resources kaminari leaflet-markercluster-rails leaflet-rails diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb new file mode 100644 index 000000000..4fbc4d806 --- /dev/null +++ b/app/controllers/api/v1/base_controller.rb @@ -0,0 +1,7 @@ +module Api + module V1 + class BaseController < JSONAPI::ResourceController + abstract + end + end +end diff --git a/app/controllers/api/v1/crops_controller.rb b/app/controllers/api/v1/crops_controller.rb new file mode 100644 index 000000000..d67beaa1a --- /dev/null +++ b/app/controllers/api/v1/crops_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class CropsController < BaseController + end + end +end diff --git a/app/controllers/api/v1/gardens_controller.rb b/app/controllers/api/v1/gardens_controller.rb new file mode 100644 index 000000000..4343d8014 --- /dev/null +++ b/app/controllers/api/v1/gardens_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class GardensController < BaseController + end + end +end diff --git a/app/controllers/api/v1/harvests_controller.rb b/app/controllers/api/v1/harvests_controller.rb new file mode 100644 index 000000000..bcf735dce --- /dev/null +++ b/app/controllers/api/v1/harvests_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class HarvestsController < BaseController + end + end +end diff --git a/app/controllers/api/v1/members_controller.rb b/app/controllers/api/v1/members_controller.rb new file mode 100644 index 000000000..b9b99956d --- /dev/null +++ b/app/controllers/api/v1/members_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class MembersController < BaseController + end + end +end diff --git a/app/controllers/api/v1/photos_controller.rb b/app/controllers/api/v1/photos_controller.rb new file mode 100644 index 000000000..a095d24cb --- /dev/null +++ b/app/controllers/api/v1/photos_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class PhotosController < BaseController + end + end +end diff --git a/app/controllers/api/v1/plantings_controller.rb b/app/controllers/api/v1/plantings_controller.rb new file mode 100644 index 000000000..d143676ab --- /dev/null +++ b/app/controllers/api/v1/plantings_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class PlantingsController < BaseController + end + end +end diff --git a/app/controllers/api/v1/seeds_controller.rb b/app/controllers/api/v1/seeds_controller.rb new file mode 100644 index 000000000..43f5691c6 --- /dev/null +++ b/app/controllers/api/v1/seeds_controller.rb @@ -0,0 +1,6 @@ +module Api + module V1 + class SeedsController < BaseController + end + end +end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 0dd3a275d..2c707f726 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -17,10 +17,8 @@ class PhotosController < ApplicationController end def new - @type = params[:type] - @id = params[:id] - @photo = Photo.new + @item = item_to_link_to retrieve_from_flickr respond_with @photo end @@ -30,9 +28,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 +50,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 +69,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 diff --git a/app/models/crop.rb b/app/models/crop.rb index 44251ec36..96ba2bc01 100644 --- a/app/models/crop.rb +++ b/app/models/crop.rb @@ -102,22 +102,11 @@ class Crop < ActiveRecord::Base Photo.joins(:harvests).where("harvests.crop_id": id) end - def as_indexed_json(_options = {}) - as_json( - only: [:id, :name, :approval_status], - include: { - scientific_names: { only: :name }, - alternate_names: { only: :name } - } - ) - end - # update the Elasticsearch index (only if we're using it in this # environment) def update_index(_name_obj) __elasticsearch__.index_document if ENV["GROWSTUFF_ELASTICSEARCH"] == "true" end - # End Elasticsearch section def to_s @@ -128,7 +117,6 @@ class Crop < ActiveRecord::Base scientific_names.first.name unless scientific_names.empty? end - # crop.default_photo # currently returns the first available photo, but exists so that # later we can choose a default photo based on different criteria, # eg. popularity @@ -140,7 +128,6 @@ class Crop < ActiveRecord::Base harvest_with_photo.photos.first if harvest_with_photo end - # crop.sunniness # returns hash indicating whether this crop is grown in # sun/semi-shade/shade # key: sunniness (eg. 'sun') @@ -149,7 +136,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'sunniness' end - # crop.planted_from # returns a hash of propagation methods (seed, seedling, etc), # key: propagation method (eg. 'seed') # value: count of how many times it's been used by plantings @@ -157,7 +143,6 @@ class Crop < ActiveRecord::Base count_uses_of_property 'planted_from' end - # crop.popular_plant_parts # returns a hash of most harvested plant parts (fruit, seed, etc) # key: plant part (eg. 'fruit') # value: count of how many times it's been used by harvests @@ -170,7 +155,7 @@ class Crop < ActiveRecord::Base end def annual? - perennial != true + !perennial end def interesting? @@ -206,13 +191,10 @@ class Crop < ActiveRecord::Base reason_for_rejection end - # # Crop.search(string) - def self.search(query) - CropSearchService.search(query) - end - - def self.case_insensitive_name(name) - where(["lower(crops.name) = :value", { value: name.downcase }]) + def update_medians + plantings.each(&:update_harvest_days) + update_lifespan_medians + update_harvest_medians end def update_lifespan_medians @@ -225,6 +207,14 @@ class Crop < ActiveRecord::Base update(median_days_to_last_harvest: Planting.where(crop: self).median(:days_to_last_harvest)) end + def self.search(query) + CropSearchService.search(query) + end + + def self.case_insensitive_name(name) + where(["lower(crops.name) = :value", { value: name.downcase }]) + end + private def count_uses_of_property(col_name) diff --git a/app/models/harvest.rb b/app/models/harvest.rb index 21339ab47..c2ad7eab1 100644 --- a/app/models/harvest.rb +++ b/app/models/harvest.rb @@ -58,6 +58,7 @@ class Harvest < ActiveRecord::Base in: WEIGHT_UNITS_VALUES.values, message: "%s is not a valid unit" } validate :crop_must_match_planting + validate :owner_must_match_planting validate :harvest_must_be_after_planting def time_from_planting_to_harvest @@ -131,6 +132,11 @@ class Harvest < ActiveRecord::Base errors.add(:planting, "must be the same crop") unless crop == planting.crop end + def owner_must_match_planting + return if planting.blank? # only check if we are linked to a planting + errors.add(:owner, "of harvest must be the same as planting") unless owner == planting.owner + end + def harvest_must_be_after_planting # only check if we are linked to a planting return unless harvested_at.present? && planting.present? && planting.planted_at.present? diff --git a/app/models/planting.rb b/app/models/planting.rb index f5f482a5d..ec0355a52 100644 --- a/app/models/planting.rb +++ b/app/models/planting.rb @@ -6,17 +6,9 @@ class Planting < ActiveRecord::Base # Constants SUNNINESS_VALUES = %w(sun semi-shade shade) PLANTED_FROM_VALUES = [ - 'seed', - 'seedling', - 'cutting', - 'root division', - 'runner', - 'bulb', - 'root/tuber', - 'bare root plant', - 'advanced plant', - 'graft', - 'layering' + 'seed', 'seedling', 'cutting', 'root division', 'runner', + 'bulb', 'root/tuber', 'bare root plant', 'advanced plant', + 'graft', 'layering' ] ## @@ -50,6 +42,7 @@ class Planting < ActiveRecord::Base validates :garden, presence: true validates :crop, presence: true, approved: { message: "must be present and exist in our database" } validate :finished_must_be_after_planted + validate :owner_must_match_garden_owner validates :quantity, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } @@ -123,12 +116,6 @@ class Planting < ActiveRecord::Base update(days_to_first_harvest: days_to_first_harvest, days_to_last_harvest: days_to_last_harvest) end - private - - def harvests_with_dates - harvests.where.not(harvested_at: nil) - end - def first_harvest_date harvests_with_dates.minimum(:harvested_at) end @@ -137,9 +124,19 @@ class Planting < ActiveRecord::Base harvests_with_dates.maximum(:harvested_at) end + private + + def harvests_with_dates + harvests.where.not(harvested_at: nil) + end + # check that any finished_at date occurs after planted_at def finished_must_be_after_planted return unless planted_at && finished_at # only check if we have both errors.add(:finished_at, "must be after the planting date") unless planted_at < finished_at end + + def owner_must_match_garden_owner + errors.add(:owner, "must be the same as garden") unless owner == garden.owner + end end diff --git a/app/resources/api/v1/base_resource.rb b/app/resources/api/v1/base_resource.rb new file mode 100644 index 000000000..f3014a8f4 --- /dev/null +++ b/app/resources/api/v1/base_resource.rb @@ -0,0 +1,8 @@ +module Api + module V1 + class BaseResource < JSONAPI::Resource + immutable + abstract + end + end +end diff --git a/app/resources/api/v1/crop_resource.rb b/app/resources/api/v1/crop_resource.rb new file mode 100644 index 000000000..86caf701a --- /dev/null +++ b/app/resources/api/v1/crop_resource.rb @@ -0,0 +1,22 @@ +module Api + module V1 + class CropResource < BaseResource + immutable + + filter :approval_status, default: 'approved' + + has_many :plantings + has_many :photos + has_many :harvests + has_one :parent + + attribute :name + attribute :en_wikipedia_url + + attribute :perennial + attribute :median_lifespan + attribute :median_days_to_first_harvest + attribute :median_days_to_last_harvest + end + end +end diff --git a/app/resources/api/v1/garden_resource.rb b/app/resources/api/v1/garden_resource.rb new file mode 100644 index 000000000..cffcb27fb --- /dev/null +++ b/app/resources/api/v1/garden_resource.rb @@ -0,0 +1,13 @@ +module Api + module V1 + class GardenResource < BaseResource + immutable + + has_one :owner, class_name: 'Member' + has_many :plantings + has_many :photos + + attribute :name + end + end +end diff --git a/app/resources/api/v1/harvest_resource.rb b/app/resources/api/v1/harvest_resource.rb new file mode 100644 index 000000000..c1ce0ae0f --- /dev/null +++ b/app/resources/api/v1/harvest_resource.rb @@ -0,0 +1,19 @@ +module Api + module V1 + class HarvestResource < BaseResource + immutable + + has_one :crop + has_one :planting + has_one :owner, class_name: 'Member' + has_many :photos + + attribute :harvested_at + attribute :description + attribute :unit + attribute :weight_quantity + attribute :weight_unit + attribute :si_weight + end + end +end diff --git a/app/resources/api/v1/member_resource.rb b/app/resources/api/v1/member_resource.rb new file mode 100644 index 000000000..b5b0a94a0 --- /dev/null +++ b/app/resources/api/v1/member_resource.rb @@ -0,0 +1,15 @@ +module Api + module V1 + class MemberResource < BaseResource + immutable + + has_many :gardens + has_many :plantings + has_many :harvests + has_many :seeds + has_many :photos + + attribute :login_name + end + end +end diff --git a/app/resources/api/v1/photo_resource.rb b/app/resources/api/v1/photo_resource.rb new file mode 100644 index 000000000..84c7eab16 --- /dev/null +++ b/app/resources/api/v1/photo_resource.rb @@ -0,0 +1,18 @@ +module Api + module V1 + class PhotoResource < BaseResource + immutable + + has_one :owner, class_name: 'Member' + has_many :plantings + has_many :gardens + has_many :harvests + + attribute :thumbnail_url + attribute :fullsize_url + attribute :license_name + attribute :link_url + attribute :title + end + end +end diff --git a/app/resources/api/v1/planting_resource.rb b/app/resources/api/v1/planting_resource.rb new file mode 100644 index 000000000..3a42f5d4b --- /dev/null +++ b/app/resources/api/v1/planting_resource.rb @@ -0,0 +1,28 @@ +module Api + module V1 + class PlantingResource < BaseResource + immutable + + has_one :garden + has_one :crop + has_one :owner, class_name: 'Member' + has_many :photos + has_many :harvests + + attribute :planted_at + attribute :finished_at + attribute :finished + attribute :quantity + attribute :description + attribute :sunniness + attribute :planted_from + + # Predictions + attribute :expected_lifespan + attribute :finish_predicted_at + attribute :percentage_grown + attribute :first_harvest_date + attribute :last_harvest_date + end + end +end diff --git a/app/resources/api/v1/seed_resource.rb b/app/resources/api/v1/seed_resource.rb new file mode 100644 index 000000000..e994ce1a0 --- /dev/null +++ b/app/resources/api/v1/seed_resource.rb @@ -0,0 +1,20 @@ +module Api + module V1 + class SeedResource < BaseResource + immutable + + has_one :owner, class_name: 'Member' + has_one :crop + + attribute :description + attribute :quantity + attribute :plant_before + attribute :tradable_to + attribute :days_until_maturity_min + attribute :days_until_maturity_max + attribute :organic + attribute :gmo + attribute :heirloom + end + end +end diff --git a/app/views/crops/_predictions.html.haml b/app/views/crops/_predictions.html.haml index 86aaf8f43..dbde9c783 100644 --- a/app/views/crops/_predictions.html.haml +++ b/app/views/crops/_predictions.html.haml @@ -10,20 +10,20 @@ an annual crop (living and reproducing in a single year or less) -- unless crop.median_lifespan.nil? +- if crop.annual? && crop.median_lifespan.present? %p Median lifespan of #{crop.name} plants is - %b= crop.median_lifespan + %strong= crop.median_lifespan days -- unless crop.median_days_to_first_harvest.nil? +- if crop.median_days_to_first_harvest.present? %p First harvest expected - %b= crop.median_days_to_first_harvest + %strong= crop.median_days_to_first_harvest days after planting -- if crop.perennial == false && crop.median_days_to_last_harvest.present? +- if crop.annual? && crop.median_days_to_last_harvest.present? %p Last harvest expected - %b= crop.median_days_to_last_harvest + %strong= crop.median_days_to_last_harvest days after planting diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml index 70f062468..ef5b41cfb 100644 --- a/app/views/gardens/show.html.haml +++ b/app/views/gardens/show.html.haml @@ -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 diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml index 4bb2013f2..31023b694 100644 --- a/app/views/photos/new.html.haml +++ b/app/views/photos/new.html.haml @@ -1,5 +1,9 @@ - content_for :title, "New Photo" +%h3 + Choose photo for + = @item + - if @flickr_auth %p Connected to Flickr as diff --git a/config/initializers/jsonapi_resources.rb b/config/initializers/jsonapi_resources.rb new file mode 100644 index 000000000..1a17dfc07 --- /dev/null +++ b/config/initializers/jsonapi_resources.rb @@ -0,0 +1,6 @@ +JSONAPI.configure do |config| + # built in paginators are :none, :offset, :paged + config.default_paginator = :offset + config.default_page_size = 10 + config.maximum_page_size = 20 +end diff --git a/config/routes.rb b/config/routes.rb index 72a3d5e19..30327901b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,8 +96,19 @@ Growstuff::Application.routes.draw do get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter get '/admin/:action' => 'admin#:action' - get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' + namespace :api do + namespace :v1 do + jsonapi_resources :photos + jsonapi_resources :crops + jsonapi_resources :plantings + jsonapi_resources :gardens + jsonapi_resources :harvests + jsonapi_resources :seeds + jsonapi_resources :members + end + end + get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt' # CMS stuff -- must remain LAST comfy_route :cms, path: '/', sitemap: false end diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb index 633311b6e..3a7559f63 100644 --- a/spec/controllers/account_types_controller_spec.rb +++ b/spec/controllers/account_types_controller_spec.rb @@ -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 AccountTypesController do diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index d159f4114..2b4222f1d 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb index a81875427..fb475b34c 100644 --- a/spec/controllers/admin/orders_controller_spec.rb +++ b/spec/controllers/admin/orders_controller_spec.rb @@ -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 diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index 6e97245d1..9f134bbab 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -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 diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb index fe7eaa61f..8b61bbddc 100644 --- a/spec/controllers/authentications_controller_spec.rb +++ b/spec/controllers/authentications_controller_spec.rb @@ -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 diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index e65a24544..23210a875 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -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 CommentsController do diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 9a0a1dcdc..1f9e06d43 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -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 diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb index f320204e2..5c59473cb 100644 --- a/spec/controllers/forums_controller_spec.rb +++ b/spec/controllers/forums_controller_spec.rb @@ -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 diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb index 5fef6e210..b0ccae0b8 100644 --- a/spec/controllers/gardens_controller_spec.rb +++ b/spec/controllers/gardens_controller_spec.rb @@ -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 diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb index ff4972a7a..8a2edb56b 100644 --- a/spec/controllers/harvests_controller_spec.rb +++ b/spec/controllers/harvests_controller_spec.rb @@ -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 @@ -25,63 +13,61 @@ describe HarvestsController do end describe "GET index" do - before do - @member1 = FactoryBot.create(:member) - @member2 = FactoryBot.create(:member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) - @harvest1 = FactoryBot.create(:harvest, owner_id: @member1.id, crop_id: @tomato.id) - @harvest2 = FactoryBot.create(:harvest, owner_id: @member2.id, crop_id: @maize.id) + let(:member1) { FactoryBot.create(:member) } + let(:member2) { FactoryBot.create(:member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } + let(:harvest1) { FactoryBot.create(:harvest, owner_id: member1.id, crop_id: tomato.id) } + let(:harvest2) { FactoryBot.create(:harvest, owner_id: member2.id, crop_id: maize.id) } + + describe "assigns all harvests as @harvests" do + before { get :index, {} } + it { assigns(:harvests).should =~ [harvest1, harvest2] } end - it "assigns all harvests as @harvests" do - get :index, {} - assigns(:harvests).should =~ [@harvest1, @harvest2] + describe "picks up owner from params and shows owner's harvests only" do + before { get :index, owner: member1.slug } + it { expect(assigns(:owner)).to eq member1 } + it { expect(assigns(:harvests)).to eq [harvest1] } end - it "picks up owner from params and shows owner's harvests only" do - get :index, owner: @member1.slug - assigns(:owner).should eq @member1 - assigns(:harvests).should eq [@harvest1] + describe "picks up crop from params and shows the harvests for the crop only" do + before { get :index, crop: maize.name } + it { expect(assigns(:crop)).to eq maize } + it { expect(assigns(:harvests)).to eq [harvest2] } end - it "picks up crop from params and shows the harvests for the crop only" do - get :index, crop: @maize.name - assigns(:crop).should eq @maize - assigns(:harvests).should eq [@harvest2] - end - - it "generates a csv" do - get :index, format: "csv" - response.status.should eq 200 + describe "generates a csv" do + before { get :index, format: "csv" } + it { expect(response.status).to eq 200 } end end describe "GET show" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :show, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :show, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end describe "GET new" do - it "assigns a new harvest as @harvest" do - get :new, {} - assigns(:harvest).should be_a_new(Harvest) + before { get :new, {} } + + describe "assigns a new harvest as @harvest" do + it { expect(assigns(:harvest)).to be_a_new(Harvest) } end - it "sets the date of the harvest to today" do - get :new, {} - assigns(:harvest).harvested_at.should == Time.zone.today + describe "sets the date of the harvest to today" do + it { expect(assigns(:harvest).harvested_at).to eq(Time.zone.today) } end end describe "GET edit" do - it "assigns the requested harvest as @harvest" do - harvest = Harvest.create! valid_attributes - get :edit, id: harvest.to_param - assigns(:harvest).should eq(harvest) + let(:harvest) { Harvest.create! valid_attributes } + describe "assigns the requested harvest as @harvest" do + before { get :edit, id: harvest.to_param } + it { expect(assigns(:harvest)).to eq(harvest) } end end @@ -104,10 +90,10 @@ describe HarvestsController do response.should redirect_to(Harvest.last) end - it "links to planting" do - planting = FactoryBot.create(:planting, owner_id: member.id) - post :create, harvest: valid_attributes.merge(planting_id: planting.id) - expect(Harvest.last.planting.id).to eq(planting.id) + describe "links to planting" do + let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) } + before { post :create, harvest: valid_attributes.merge(planting_id: planting.id) } + it { expect(Harvest.last.planting.id).to eq(planting.id) } end end @@ -129,10 +115,13 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - allow(Harvest).to receive(:new).and_return(harvest) - post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + + describe "does not save planting_id" do + before do + allow(Harvest).to receive(:new).and_return(harvest) + post :create, harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).not_to eq(not_my_planting.id) } end end end @@ -181,10 +170,12 @@ describe HarvestsController do describe "not my planting" do let(:not_my_planting) { FactoryBot.create(:planting) } let(:harvest) { FactoryBot.create(:harvest) } - it "does not save planting_id" do - put :update, id: harvest.to_param, - harvest: valid_attributes.merge(planting_id: not_my_planting.id) - expect(harvest.planting_id).to eq(nil) + describe "does not save planting_id" do + before do + put :update, id: harvest.to_param, + harvest: valid_attributes.merge(planting_id: not_my_planting.id) + end + it { expect(harvest.planting_id).to eq(nil) } end end end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index eb71e1f4a..cb12b2bb4 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -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 diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb index 866507f5f..b04bcd799 100644 --- a/spec/controllers/member_controller_spec.rb +++ b/spec/controllers/member_controller_spec.rb @@ -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 diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 0619a6707..fd6f40aa1 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -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 diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb index 0c1b50706..1da3c3b8d 100644 --- a/spec/controllers/order_items_controller_spec.rb +++ b/spec/controllers/order_items_controller_spec.rb @@ -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 OrderItemsController do diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb index d02fc6e27..3c6631d8c 100644 --- a/spec/controllers/orders_controller_spec.rb +++ b/spec/controllers/orders_controller_spec.rb @@ -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 diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 7c935422c..3c4f9dacb 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -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 diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb index 79c1dc623..8b6cb0a31 100644 --- a/spec/controllers/places_controller_spec.rb +++ b/spec/controllers/places_controller_spec.rb @@ -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 diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb index 239422efa..c6e11f315 100644 --- a/spec/controllers/plant_parts_controller_spec.rb +++ b/spec/controllers/plant_parts_controller_spec.rb @@ -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 diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb index e9ce41369..1bacacc8c 100644 --- a/spec/controllers/plantings_controller_spec.rb +++ b/spec/controllers/plantings_controller_spec.rb @@ -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 diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index 4cd61d242..cbfe8b46c 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -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 diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 63c17aa66..173ef9ba4 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -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 diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index c69144fd6..015bbb705 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -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 diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index 5c2271bce..9bf0ea1b5 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -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 diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb index 64b1e97fe..412f53224 100644 --- a/spec/controllers/scientific_names_controller_spec.rb +++ b/spec/controllers/scientific_names_controller_spec.rb @@ -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 diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb index 9ae6af1e2..c2fd699eb 100644 --- a/spec/controllers/seeds_controller_spec.rb +++ b/spec/controllers/seeds_controller_spec.rb @@ -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 diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 4a438ea76..6298b7e76 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -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 ShopController do diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb index e1ff04fb3..c707a2e2c 100644 --- a/spec/factories/harvests.rb +++ b/spec/factories/harvests.rb @@ -2,15 +2,20 @@ FactoryBot.define do factory :harvest do - crop + crop { planting.present? ? planting.crop : FactoryBot.create(:crop) } plant_part - owner + planting nil + owner { planting.present? ? planting.owner : FactoryBot.create(:member) } harvested_at Time.zone.local(2015, 9, 17) quantity "3" unit "individual" weight_quantity 6 weight_unit "kg" description "A lovely harvest" + + factory :harvest_with_planting do + planting + end end trait :long_description do diff --git a/spec/factories/planting.rb b/spec/factories/planting.rb index 2deb014c5..2bcfac397 100644 --- a/spec/factories/planting.rb +++ b/spec/factories/planting.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory :planting do - garden owner + garden { FactoryBot.create :garden, owner: owner } crop planted_at Time.zone.local(2014, 7, 30) quantity 33 diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb index 45d855bc2..05ebdb6e7 100644 --- a/spec/features/crops/crop_detail_page_spec.rb +++ b/spec/features/crops/crop_detail_page_spec.rb @@ -169,41 +169,56 @@ feature "crop detail page", js: true do end end - shared_examples "lots of harvests" do - def planting - FactoryBot.create :planting, crop: crop, planted_at: 100.days.ago, finished_at: 1.day.ago + shared_examples "predicts harvest" do + describe 'with harvest history data' do + before do + # 50 days to harvest + FactoryBot.create(:harvest, harvested_at: 150.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + # 20 days to harvest + FactoryBot.create(:harvest, harvested_at: 180.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + # 10 days to harvest + FactoryBot.create(:harvest, harvested_at: 190.days.ago, crop: planting.crop, + planting: FactoryBot.create(:planting, planted_at: 200.days.ago, crop: crop)) + end + it "predicts harvest" do + is_expected.to have_text("First harvest expected 20 days after planting") + end end - before do - # 50 days to harvest - FactoryBot.create(:harvest, harvested_at: 50.days.ago, crop: crop, planting: planting) - # 20 days to harvest - FactoryBot.create(:harvest, harvested_at: 80.days.ago, crop: crop, planting: planting) - # 10 days to harvest - FactoryBot.create(:harvest, harvested_at: 90.days.ago, crop: crop, planting: planting) - planting.crop.plantings.each(&:update_harvest_days) - planting.crop.update_lifespan_medians - planting.crop.update_harvest_medians - end - it { is_expected.to have_text("First harvest expected 20 days after planting") } - it { is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" } end subject do + # Update the medians after all the + # data has been loaded + crop.reload + crop.update_medians + visit crop_path(crop) page end context 'predictions' do + let!(:planting) do + FactoryBot.create(:planting, crop: crop, + planted_at: 100.days.ago, + finished_at: 1.day.ago) + end context 'crop is an annual' do - let(:crop) { FactoryBot.create :annual_crop } + let(:crop) { FactoryBot.create(:annual_crop) } describe 'with no harvests' do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end - it do + + it "predicts lifespan" do + is_expected.to have_text "Median lifespan of #{crop.name} plants is 99 days" + end + + it "describes annual crops" do is_expected.to have_text( "#{crop.name} is an annual crop (living and reproducing in a single year or less)" ) @@ -217,9 +232,12 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" + end + + it "describes perennial crops" do + is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") end - it { is_expected.to have_text("#{crop.name} is a perennial crop (living more than two years)") } end context 'crop perennial value is null' do @@ -229,7 +247,7 @@ feature "crop detail page", js: true do end describe 'with harvests' do - include_examples "lots of harvests" + include_examples "predicts harvest" end end end diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb index 3d78cbe5d..e9a20d060 100644 --- a/spec/features/gardens_spec.rb +++ b/spec/features/gardens_spec.rb @@ -2,9 +2,9 @@ require 'rails_helper' feature "Planting a crop", js: true do let!(:garden) { create :garden } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + 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, garden: garden, crop: tomato } + let!(:finished_planting) { create :finished_planting, owner: garden.owner, garden: garden, crop: tomato } background do login_as garden.owner diff --git a/spec/features/photos/new_photo_spec.rb b/spec/features/photos/new_photo_spec.rb new file mode 100644 index 000000000..0f0c8af2c --- /dev/null +++ b/spec/features/photos/new_photo_spec.rb @@ -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" + 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 diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb index 177cf9942..0c984837b 100644 --- a/spec/features/plantings/planting_a_crop_spec.rb +++ b/spec/features/plantings/planting_a_crop_spec.rb @@ -5,7 +5,9 @@ feature "Planting a crop", :js, :elasticsearch do let(:member) { create :member } let!(:maize) { create :maize } let(:garden) { create :garden, owner: member } - let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") } + let!(:planting) do + create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") + end background do login_as member diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 433286078..a6402df2c 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -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 diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index 406a65eb0..860e2e935 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -348,7 +348,23 @@ describe Crop do end end + let(:maize) { FactoryBot.create(:maize) } + let(:pp1) { FactoryBot.create(:plant_part) } + let(:pp2) { FactoryBot.create(:plant_part) } + context "harvests" do + let(:h1) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp1) + end + + let(:h2) do + FactoryBot.create(:harvest, + crop: maize, + plant_part: pp2) + end + it "has harvests" do crop = FactoryBot.create(:crop) harvest = FactoryBot.create(:harvest, crop: crop) @@ -356,20 +372,6 @@ describe Crop do end end - it 'has plant_parts' do - @maize = FactoryBot.create(:maize) - @pp1 = FactoryBot.create(:plant_part) - @pp2 = FactoryBot.create(:plant_part) - @h1 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp1) - @h2 = FactoryBot.create(:harvest, - crop: @maize, - plant_part: @pp2) - @maize.plant_parts.should include @pp1 - @maize.plant_parts.should include @pp2 - end - it "doesn't duplicate plant_parts" do @maize = FactoryBot.create(:maize) @pp1 = FactoryBot.create(:plant_part) @@ -385,9 +387,7 @@ describe Crop do context "search", :elasticsearch do let(:mushroom) { FactoryBot.create(:crop, name: 'mushroom') } - before do - sync_elasticsearch([mushroom]) - end + before { sync_elasticsearch([mushroom]) } it "finds exact matches" do Crop.search('mushroom').should eq [mushroom] diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb index 867b333d1..cbb097d91 100644 --- a/spec/models/garden_spec.rb +++ b/spec/models/garden_spec.rb @@ -64,30 +64,30 @@ describe Garden do let(:walnut) { FactoryBot.create(:walnut) } it "should fetch < 4 featured plantings if insufficient exist" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p2, @p1] end it "should fetch most recent 4 featured plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p5, @p4, @p3, @p2] end it "should skip repeated plantings" do - @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden) - @p2 = FactoryBot.create(:planting, crop: maize, garden: garden) - @p3 = FactoryBot.create(:planting, crop: chard, garden: garden) - @p4 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden) - @p6 = FactoryBot.create(:planting, crop: apple, garden: garden) - @p7 = FactoryBot.create(:planting, crop: pear, garden: garden) + @p1 = FactoryBot.create(:planting, crop: tomato, garden: garden, owner: garden.owner) + @p2 = FactoryBot.create(:planting, crop: maize, garden: garden, owner: garden.owner) + @p3 = FactoryBot.create(:planting, crop: chard, garden: garden, owner: garden.owner) + @p4 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p5 = FactoryBot.create(:planting, crop: walnut, garden: garden, owner: garden.owner) + @p6 = FactoryBot.create(:planting, crop: apple, garden: garden, owner: garden.owner) + @p7 = FactoryBot.create(:planting, crop: pear, garden: garden, owner: garden.owner) garden.featured_plantings.should eq [@p7, @p6, @p5, @p3] end @@ -103,8 +103,8 @@ describe Garden do it "destroys plantings when deleted" do garden = FactoryBot.create(:garden, owner: owner) - @planting1 = FactoryBot.create(:planting, garden: garden) - @planting2 = FactoryBot.create(:planting, garden: garden) + @planting1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + @planting2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) garden.plantings.size.should eq(2) all = Planting.count garden.destroy @@ -185,8 +185,8 @@ describe Garden do it "marks plantings as finished when garden is inactive" do garden = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: garden) - p2 = FactoryBot.create(:planting, garden: garden) + p1 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) + p2 = FactoryBot.create(:planting, garden: garden, owner: garden.owner) p1.finished.should eq false p2.finished.should eq false @@ -203,8 +203,8 @@ describe Garden do it "doesn't mark the wrong plantings as finished" do g1 = FactoryBot.create(:garden) g2 = FactoryBot.create(:garden) - p1 = FactoryBot.create(:planting, garden: g1) - p2 = FactoryBot.create(:planting, garden: g2) + p1 = FactoryBot.create(:planting, garden: g1, owner: g1.owner) + p2 = FactoryBot.create(:planting, garden: g2, owner: g2.owner) # mark the garden as inactive g1.active = false diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb index 462bee3e4..ec9eb0746 100644 --- a/spec/models/planting_spec.rb +++ b/spec/models/planting_spec.rb @@ -4,7 +4,7 @@ describe Planting do let(:crop) { FactoryBot.create(:tomato) } let(:garden_owner) { FactoryBot.create(:member) } let(:garden) { FactoryBot.create(:garden, owner: garden_owner) } - let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden) } + let(:planting) { FactoryBot.create(:planting, crop: crop, garden: garden, owner: garden.owner) } let(:finished_planting) do FactoryBot.create :planting, planted_at: 4.days.ago, finished_at: 2.days.ago, finished: true end @@ -120,7 +120,10 @@ describe Planting do describe 'planting has first harvest' do let(:planting) { FactoryBot.create :planting, planted_at: 100.days.ago } before do - FactoryBot.create :harvest, planting: planting, crop: planting.crop, harvested_at: 10.days.ago + FactoryBot.create(:harvest, + planting: planting, + crop: planting.crop, + harvested_at: 10.days.ago) planting.update_harvest_days planting.crop.update_harvest_medians end @@ -148,12 +151,6 @@ describe Planting do planting.owner.should be_an_instance_of Member end - it "owner isn't necessarily the garden owner" do - # a new owner should be created automatically by FactoryBot - # note that formerly, the planting belonged to an owner through the garden - planting.owner.should_not eq garden_owner - end - it "generates a location" do planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}" end @@ -355,7 +352,8 @@ describe Planting do # this one is newer, and has the same owner, through the garden @planting2 = FactoryBot.create(:planting, created_at: 1.minute.ago, - owner_id: @planting1.owner.id) + garden: @planting1.garden, + owner: @planting1.owner) @planting2.photos << FactoryBot.create(:photo) @planting2.save diff --git a/spec/requests/api/v1/crop_request_spec.rb b/spec/requests/api/v1/crop_request_spec.rb new file mode 100644 index 000000000..cfac5fdb4 --- /dev/null +++ b/spec/requests/api/v1/crop_request_spec.rb @@ -0,0 +1,87 @@ +require 'rails_helper' + +RSpec.describe 'Plantings', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:crop) { FactoryBot.create :crop } + let(:crop_encoded_as_json_api) do + { "id" => crop.id.to_s, + "type" => "crops", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "plantings" => plantings_as_json_api, + "parent" => parent_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/crops/#{crop.id}" } + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:parent_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/parent", + "related" => "#{resource_url}/parent" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:attributes) do + { + "name" => crop.name, + "en-wikipedia-url" => crop.en_wikipedia_url, + "perennial" => false, + "median-lifespan" => nil, + "median-days-to-first-harvest" => nil, + "median-days-to-last-harvest" => nil + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/crops', {}, headers } + it { expect(subject['data']).to include(crop_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/crops/#{crop.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("parent" => parent_as_json_api) } + it { expect(subject['data']).to eq(crop_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/crops', { 'crop' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/crops/#{crop.id}", { 'crop' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/crops/#{crop.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end diff --git a/spec/requests/api/v1/gardens_request_spec.rb b/spec/requests/api/v1/gardens_request_spec.rb new file mode 100644 index 000000000..65caf7044 --- /dev/null +++ b/spec/requests/api/v1/gardens_request_spec.rb @@ -0,0 +1,64 @@ +require 'rails_helper' + +RSpec.describe 'Gardens', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:garden) { FactoryBot.create :garden } + let(:garden_encoded_as_json_api) do + { "id" => garden.id.to_s, + "type" => "gardens", + "links" => { "self" => resource_url }, + "attributes" => { "name" => garden.name }, + "relationships" => + { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "photos" => photos_as_json_api + } } + end + let(:resource_url) { "http://www.example.com/api/v1/gardens/#{garden.id}" } + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + subject { JSON.parse response.body } + scenario '#index' do + get '/api/v1/gardens', {}, headers + expect(subject['data']).to include(garden_encoded_as_json_api) + end + + scenario '#show' do + get "/api/v1/gardens/#{garden.id}", {}, headers + expect(subject['data']).to include(garden_encoded_as_json_api) + end + + scenario '#create' do + post '/api/v1/gardens', { 'garden' => { 'name' => 'can i make this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#update' do + post "/api/v1/gardens/#{garden.id}", { 'garden' => { 'name' => 'can i modify this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#delete' do + delete "/api/v1/gardens/#{garden.id}", {}, headers + expect(response.code).to eq "404" + end +end diff --git a/spec/requests/api/v1/harvest_request_spec.rb b/spec/requests/api/v1/harvest_request_spec.rb new file mode 100644 index 000000000..7d97dea08 --- /dev/null +++ b/spec/requests/api/v1/harvest_request_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +RSpec.describe 'Harvests', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:harvest) { FactoryBot.create :harvest } + let(:harvest_encoded_as_json_api) do + { "id" => harvest.id.to_s, + "type" => "harvests", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "crop" => crop_as_json_api, + "planting" => planting_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/harvests/#{harvest.id}" } + + let(:crop_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:planting_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/planting", + "related" => "#{resource_url}/planting" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:attributes) do + { + "harvested-at" => "2015-09-17", + "description" => harvest.description, + "unit" => harvest.unit, + "weight-quantity" => harvest.weight_quantity.to_s, + "weight-unit" => harvest.weight_unit, + "si-weight" => harvest.si_weight + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/harvests', {}, headers } + it { expect(subject['data']).to include(harvest_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/harvests/#{harvest.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("planting" => planting_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']).to eq(harvest_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/harvests', { 'harvest' => { 'description' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/harvests/#{harvest.id}", { 'harvest' => { 'description' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/harvests/#{harvest.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end diff --git a/spec/requests/api/v1/member_request_spec.rb b/spec/requests/api/v1/member_request_spec.rb new file mode 100644 index 000000000..0c74dc3cd --- /dev/null +++ b/spec/requests/api/v1/member_request_spec.rb @@ -0,0 +1,88 @@ +require 'rails_helper' + +RSpec.describe 'Members', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:member) { FactoryBot.create :member } + let(:member_encoded_as_json_api) do + { "id" => member.id.to_s, + "type" => "members", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "gardens" => gardens_as_json_api, + "harvests" => harvests_as_json_api, + "photos" => photos_as_json_api, + "plantings" => plantings_as_json_api, + "seeds" => seeds_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/members/#{member.id}" } + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:seeds_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/seeds", + "related" => "#{resource_url}/seeds" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + let(:gardens_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } + end + + let(:attributes) do + { + "login-name" => member.login_name + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/members', {}, headers } + it { expect(subject['data']).to include(member_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/members/#{member.id}", {}, headers } + it { expect(subject['data']['relationships']).to include("gardens" => gardens_as_json_api) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("seeds" => seeds_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) } + it { expect(subject['data']).to eq(member_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/members', { 'member' => { 'login_name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/members/#{member.id}", { 'member' => { 'login_name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/members/#{member.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end diff --git a/spec/requests/api/v1/photos_request_spec.rb b/spec/requests/api/v1/photos_request_spec.rb new file mode 100644 index 000000000..cb205d972 --- /dev/null +++ b/spec/requests/api/v1/photos_request_spec.rb @@ -0,0 +1,85 @@ +require 'rails_helper' + +RSpec.describe 'Photos', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:photo) { FactoryBot.create :photo } + let(:photo_encoded_as_json_api) do + { "id" => photo.id.to_s, + "type" => "photos", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "plantings" => plantings_as_json_api, + "harvests" => harvests_as_json_api, + "gardens" => gardens_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/photos/#{photo.id}" } + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:gardens_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/gardens", + "related" => "#{resource_url}/gardens" } } + end + + let(:plantings_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/plantings", + "related" => "#{resource_url}/plantings" } } + end + + let(:attributes) do + { + "thumbnail-url" => photo.thumbnail_url, + "fullsize-url" => photo.fullsize_url, + "link-url" => photo.link_url, + "license-name" => photo.license_name, + "title" => photo.title + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/photos', {}, headers } + it { expect(subject['data']).to include(photo_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/photos/#{photo.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("plantings" => plantings_as_json_api) } + it { expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']).to eq(photo_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/photos', { 'photo' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/photos/#{photo.id}", { 'photo' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/photos/#{photo.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end diff --git a/spec/requests/api/v1/plantings_request_spec.rb b/spec/requests/api/v1/plantings_request_spec.rb new file mode 100644 index 000000000..0591a28dc --- /dev/null +++ b/spec/requests/api/v1/plantings_request_spec.rb @@ -0,0 +1,99 @@ +require 'rails_helper' + +RSpec.describe 'Plantings', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:planting) { FactoryBot.create :planting } + let(:planting_encoded_as_json_api) do + { "id" => planting.id.to_s, + "type" => "plantings", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "garden" => garden_as_json_api, + "crop" => crop_as_json_api, + "owner" => owner_as_json_api, + "photos" => photos_as_json_api, + "harvests" => harvests_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/plantings/#{planting.id}" } + + let(:harvests_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/harvests", + "related" => "#{resource_url}/harvests" } } + end + + let(:photos_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/photos", + "related" => "#{resource_url}/photos" } } + end + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:crop_as_json_api) do + { "links" => + { "self" => + "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } + end + let(:garden_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/garden", + "related" => "#{resource_url}/garden" } } + end + + let(:attributes) do + { + "planted-at" => "2014-07-30", + "finished-at" => nil, + "finished" => false, + "quantity" => 33, + "description" => planting.description, + "sunniness" => nil, + "planted-from" => nil, + "expected-lifespan" => nil, + "finish-predicted-at" => nil, + "percentage-grown" => nil, + "first-harvest-date" => nil, + "last-harvest-date" => nil + } + end + + subject { JSON.parse response.body } + scenario '#index' do + get '/api/v1/plantings', {}, headers + expect(subject['data']).to include(planting_encoded_as_json_api) + end + + scenario '#show' do + get "/api/v1/plantings/#{planting.id}", {}, headers + expect(subject['data']['relationships']).to include("garden" => garden_as_json_api) + expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) + expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) + expect(subject['data']['relationships']).to include("harvests" => harvests_as_json_api) + expect(subject['data']['relationships']).to include("photos" => photos_as_json_api) + expect(subject['data']).to eq(planting_encoded_as_json_api) + end + + scenario '#create' do + post '/api/v1/plantings', { 'planting' => { 'description' => 'can i make this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#update' do + post "/api/v1/plantings/#{planting.id}", { 'planting' => { 'description' => 'can i modify this' } }, headers + expect(response.code).to eq "404" + end + + scenario '#delete' do + delete "/api/v1/plantings/#{planting.id}", {}, headers + expect(response.code).to eq "404" + end +end diff --git a/spec/requests/api/v1/seeds_request_spec.rb b/spec/requests/api/v1/seeds_request_spec.rb new file mode 100644 index 000000000..41d622a1f --- /dev/null +++ b/spec/requests/api/v1/seeds_request_spec.rb @@ -0,0 +1,73 @@ +require 'rails_helper' + +RSpec.describe 'Photos', type: :request do + let(:headers) { { 'Accept' => 'application/vnd.api+json' } } + let!(:seed) { FactoryBot.create :seed } + let(:seed_encoded_as_json_api) do + { "id" => seed.id.to_s, + "type" => "seeds", + "links" => { "self" => resource_url }, + "attributes" => attributes, + "relationships" => { + "owner" => owner_as_json_api, + "crop" => crop_as_json_api + } } + end + + let(:resource_url) { "http://www.example.com/api/v1/seeds/#{seed.id}" } + + let(:owner_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/owner", + "related" => "#{resource_url}/owner" } } + end + + let(:crop_as_json_api) do + { "links" => + { "self" => "#{resource_url}/relationships/crop", + "related" => "#{resource_url}/crop" } } + end + + let(:attributes) do + { + "description" => seed.description, + "quantity" => seed.quantity, + "plant-before" => "2013-07-15", + "tradable-to" => seed.tradable_to, + "days-until-maturity-min" => seed.days_until_maturity_min, + "days-until-maturity-max" => seed.days_until_maturity_max, + "organic" => seed.organic, + "gmo" => seed.gmo, + "heirloom" => seed.heirloom + } + end + + subject { JSON.parse response.body } + describe '#index' do + before { get '/api/v1/seeds', {}, headers } + it { expect(subject['data']).to include(seed_encoded_as_json_api) } + end + + describe '#show' do + before { get "/api/v1/seeds/#{seed.id}", {}, headers } + it { expect(subject['data']['attributes']).to eq(attributes) } + it { expect(subject['data']['relationships']).to include("owner" => owner_as_json_api) } + it { expect(subject['data']['relationships']).to include("crop" => crop_as_json_api) } + it { expect(subject['data']).to eq(seed_encoded_as_json_api) } + end + + describe '#create' do + before { post '/api/v1/seeds', { 'seed' => { 'name' => 'can i make this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#update' do + before { post "/api/v1/seeds/#{seed.id}", { 'seed' => { 'name' => 'can i modify this' } }, headers } + it { expect(response.code).to eq "404" } + end + + describe '#delete' do + before { delete "/api/v1/seeds/#{seed.id}", {}, headers } + it { expect(response.code).to eq "404" } + end +end diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb index 09bcc35ce..1bd22be03 100644 --- a/spec/views/account_types/edit.html.haml_spec.rb +++ b/spec/views/account_types/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb index b5aa55b17..56020fc35 100644 --- a/spec/views/account_types/index.html.haml_spec.rb +++ b/spec/views/account_types/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb index 3efc39b05..027a1b7c1 100644 --- a/spec/views/account_types/new.html.haml_spec.rb +++ b/spec/views/account_types/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb index 828639f00..a31d4bc33 100644 --- a/spec/views/account_types/show.html.haml_spec.rb +++ b/spec/views/account_types/show.html.haml_spec.rb @@ -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 diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb index 96b29ef75..bc5c3b5a3 100644 --- a/spec/views/accounts/edit.html.haml_spec.rb +++ b/spec/views/accounts/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb index 5d23d9d76..4ec76151e 100644 --- a/spec/views/accounts/index.html.haml_spec.rb +++ b/spec/views/accounts/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb index 6ba4da067..77f6ff20f 100644 --- a/spec/views/accounts/new.html.haml_spec.rb +++ b/spec/views/accounts/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb index 71be40505..d96fbbd96 100644 --- a/spec/views/accounts/show.html.haml_spec.rb +++ b/spec/views/accounts/show.html.haml_spec.rb @@ -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 diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb index 1c5f9bd20..beb0eacbd 100644 --- a/spec/views/admin/index_spec.rb +++ b/spec/views/admin/index_spec.rb @@ -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 diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb index 901e3a12a..384833034 100644 --- a/spec/views/admin/newsletter_spec.rb +++ b/spec/views/admin/newsletter_spec.rb @@ -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 diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb index c819f0268..8d80dc3ef 100644 --- a/spec/views/admin/orders/index_spec.rb +++ b/spec/views/admin/orders/index_spec.rb @@ -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 diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb index e562ca027..2ef7d480f 100644 --- a/spec/views/comments/edit.html.haml_spec.rb +++ b/spec/views/comments/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb index 1bf0e734f..91ed15a88 100644 --- a/spec/views/comments/index.html.haml_spec.rb +++ b/spec/views/comments/index.html.haml_spec.rb @@ -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 diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb index c3b6fdd32..672658bac 100644 --- a/spec/views/comments/index.rss.haml_spec.rb +++ b/spec/views/comments/index.rss.haml_spec.rb @@ -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 diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb index 074b5bfe5..e0533ea5b 100644 --- a/spec/views/comments/new.html.haml_spec.rb +++ b/spec/views/comments/new.html.haml_spec.rb @@ -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 diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb index baf02cbbb..6315b4f69 100644 --- a/spec/views/comments/show.html.haml_spec.rb +++ b/spec/views/comments/show.html.haml_spec.rb @@ -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 diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb index 290d5d8c6..c378c296c 100644 --- a/spec/views/crops/_grown_for.html.haml_spec.rb +++ b/spec/views/crops/_grown_for.html.haml_spec.rb @@ -1,29 +1,17 @@ -## 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 - before(:each) do - @crop = FactoryBot.create(:crop) - @pp = FactoryBot.create(:plant_part) - @harvest = FactoryBot.create(:harvest, - crop: @crop, - plant_part: @pp) + let(:crop) { FactoryBot.create(:crop) } + let(:plant_path) { FactoryBot.create(:plant_part) } + let!(:harvest) do + FactoryBot.create(:harvest, + crop: crop, + plant_part: plant_path) end it 'shows plant parts' do - render partial: 'crops/grown_for', locals: { crop: @crop } - rendered.should have_content @pp.name - assert_select "a", href: plant_part_path(@pp) + render partial: 'crops/grown_for', locals: { crop: crop } + rendered.should have_content plant_path.name + assert_select "a", href: plant_part_path(plant_path) end end diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb index 58df0584d..c7a4719b5 100644 --- a/spec/views/crops/_planting_advice.html.haml_spec.rb +++ b/spec/views/crops/_planting_advice.html.haml_spec.rb @@ -1,70 +1,62 @@ -## 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 - before(:each) do - @owner = FactoryBot.create(:member) - @crop = FactoryBot.create(:crop) - @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, - garden: @garden, - crop: @crop) + let(:planting) { FactoryBot.create(:planting) } + subject { rendered } + + shared_examples "render planting_advice" do + before { render 'crops/planting_advice', crop: planting.crop } end - context "sunniness" do - it "doesn't show sunniness if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in: not known." + describe "sunniness" do + context "with no sunniness set" do + include_examples "render planting_advice" + it "doesn't show sunniness" do + is_expected.to have_content "Plant in: not known." + end end - it "shows sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (1)" + context "with sunniness frequencies" do + before { FactoryBot.create(:sunny_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (1)" } end - it "shows multiple sunniness frequencies" do - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:sunny_planting, crop: @crop) - FactoryBot.create(:shady_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant in:" - rendered.should have_content "sun (2), shade (1)" + context "with multiple sunniness frequencies" do + before do + FactoryBot.create_list(:sunny_planting, 2, crop: planting.crop) + FactoryBot.create(:shady_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant in:" } + it { is_expected.to have_content "sun (2), shade (1)" } end end - context "planted from" do - it "doesn't show planted_from if none are set" do - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from: not known." + describe "planted from" do + context "when none are set" do + include_examples "render planting_advice" + it "doesn't show planted_from " do + is_expected.to have_content "Plant from: not known." + end end - it "shows planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (1)" + context "with planted_from frequencies" do + before { FactoryBot.create(:seed_planting, crop: planting.crop) } + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (1)" } end - it "shows multiple planted_from frequencies" do - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:seed_planting, crop: @crop) - FactoryBot.create(:cutting_planting, crop: @crop) - render partial: 'crops/planting_advice', locals: { crop: @crop } - rendered.should have_content "Plant from:" - rendered.should have_content "seed (2), cutting (1)" + context "with multiple planted_from frequencies" do + before do + FactoryBot.create_list(:seed_planting, 2, crop: planting.crop) + FactoryBot.create(:cutting_planting, crop: planting.crop) + end + include_examples "render planting_advice" + it { is_expected.to have_content "Plant from:" } + it { is_expected.to have_content "seed (2), cutting (1)" } end end end diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb index 35d508fd8..dde4a893f 100644 --- a/spec/views/crops/_popover.html.haml_spec.rb +++ b/spec/views/crops/_popover.html.haml_spec.rb @@ -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 diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb index 03f333bf2..eed85528d 100644 --- a/spec/views/crops/edit.html.haml_spec.rb +++ b/spec/views/crops/edit.html.haml_spec.rb @@ -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 diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb index c711b2174..833bb2b98 100644 --- a/spec/views/crops/hierarchy.html.haml_spec.rb +++ b/spec/views/crops/hierarchy.html.haml_spec.rb @@ -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/hierarchy" do diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb index 421e33e00..9f2985035 100644 --- a/spec/views/crops/index.html.haml_spec.rb +++ b/spec/views/crops/index.html.haml_spec.rb @@ -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/index" do diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb index 623fb296e..72a8bbdff 100644 --- a/spec/views/crops/index.rss.haml_spec.rb +++ b/spec/views/crops/index.rss.haml_spec.rb @@ -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/index.rss.haml' do diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb index a1208352a..5ce7eefdc 100644 --- a/spec/views/crops/new.html.haml_spec.rb +++ b/spec/views/crops/new.html.haml_spec.rb @@ -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/new" do diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb index 6550026f6..085060570 100644 --- a/spec/views/crops/wrangle.html.haml_spec.rb +++ b/spec/views/crops/wrangle.html.haml_spec.rb @@ -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/wrangle" do diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb index 01e0d7230..d2cce98c4 100644 --- a/spec/views/devise/mailer/confirmation_instructions_spec.rb +++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb @@ -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 'devise/mailer/confirmation_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb index 7d0cdfe6a..fc2ad1bbe 100644 --- a/spec/views/devise/mailer/reset_password_instructions_spec.rb +++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb @@ -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 'devise/mailer/reset_password_instructions.html.haml', type: "view" do diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb index 693fe97b0..633545cf3 100644 --- a/spec/views/devise/mailer/unlock_instructions_spec.rb +++ b/spec/views/devise/mailer/unlock_instructions_spec.rb @@ -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 'devise/mailer/unlock_instructions.html.haml', type: "view" do context "logged in" do diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb index 7c69a8d3e..3d9dae906 100644 --- a/spec/views/devise/registrations/edit_spec.rb +++ b/spec/views/devise/registrations/edit_spec.rb @@ -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 'devise/registrations/edit.html.haml', type: "view" do diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb index be00abae9..48805b806 100644 --- a/spec/views/devise/registrations/new_spec.rb +++ b/spec/views/devise/registrations/new_spec.rb @@ -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 'devise/registrations/new.html.haml', type: "view" do diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb index 93b14b9c3..dfe91af2a 100644 --- a/spec/views/devise/sessions/new_spec.rb +++ b/spec/views/devise/sessions/new_spec.rb @@ -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 'devise/sessions/new.html.haml', type: "view" do diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb index c53968a8d..60d056d72 100644 --- a/spec/views/devise/unlocks/new_spec.rb +++ b/spec/views/devise/unlocks/new_spec.rb @@ -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 'devise/unlocks/new.html.haml', type: "view" do diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb index d7d426a8e..44151170a 100644 --- a/spec/views/forums/edit.html.haml_spec.rb +++ b/spec/views/forums/edit.html.haml_spec.rb @@ -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 "forums/edit" do diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb index cf8377858..02b265e85 100644 --- a/spec/views/forums/index.html.haml_spec.rb +++ b/spec/views/forums/index.html.haml_spec.rb @@ -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 "forums/index" do diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb index 8c95c7c1f..72cd7ae45 100644 --- a/spec/views/forums/new.html.haml_spec.rb +++ b/spec/views/forums/new.html.haml_spec.rb @@ -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 "forums/new" do diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb index 5b6bae8fa..08892df58 100644 --- a/spec/views/forums/show.html.haml_spec.rb +++ b/spec/views/forums/show.html.haml_spec.rb @@ -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 "forums/show" do diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb index 1928f6d8b..1326f1544 100644 --- a/spec/views/gardens/edit.html.haml_spec.rb +++ b/spec/views/gardens/edit.html.haml_spec.rb @@ -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 "gardens/edit" do diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb index 97eab872e..7346997dc 100644 --- a/spec/views/gardens/new.html.haml_spec.rb +++ b/spec/views/gardens/new.html.haml_spec.rb @@ -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 "gardens/new" do diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb index 83f993a16..015333ae0 100644 --- a/spec/views/gardens/show.html.haml_spec.rb +++ b/spec/views/gardens/show.html.haml_spec.rb @@ -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 "gardens/show" do @@ -17,7 +5,7 @@ describe "gardens/show" do @owner = FactoryBot.create(:member) controller.stub(:current_user) { @owner } @garden = FactoryBot.create(:garden, owner: @owner) - @planting = FactoryBot.create(:planting, garden: @garden) + @planting = FactoryBot.create(:planting, garden: @garden, owner: @garden.owner) assign(:garden, @garden) assign(:current_plantings, [@planting]) assign(:finished_plantings, []) diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb index a475a6300..1193b4284 100644 --- a/spec/views/harvests/edit.html.haml_spec.rb +++ b/spec/views/harvests/edit.html.haml_spec.rb @@ -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 "harvests/edit" do diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb index db9ce915f..fe205cda6 100644 --- a/spec/views/harvests/index.html.haml_spec.rb +++ b/spec/views/harvests/index.html.haml_spec.rb @@ -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 "harvests/index" do diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb index 4b792a4c6..d79055a38 100644 --- a/spec/views/harvests/new.html.haml_spec.rb +++ b/spec/views/harvests/new.html.haml_spec.rb @@ -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 "harvests/new" do diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb index 129648c71..5e2f167af 100644 --- a/spec/views/harvests/show.html.haml_spec.rb +++ b/spec/views/harvests/show.html.haml_spec.rb @@ -1,28 +1,19 @@ -## 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 "harvests/show" do - before(:each) do + let!(:harvest) { FactoryBot.create(:harvest) } + + before do controller.stub(:current_user) { nil } - @crop = FactoryBot.create(:tomato) - @harvest = assign(:harvest, FactoryBot.create(:harvest, crop: @crop)) + assign(:harvest, harvest) render end - it "renders attributes" do - rendered.should have_content @crop.name - rendered.should have_content @harvest.harvested_at.to_s - rendered.should have_content @harvest.plant_part.to_s + subject { render } + + describe "renders attributes" do + it { is_expected.to have_content harvest.crop.name } + it { is_expected.to have_content harvest.harvested_at.to_s } + it { is_expected.to have_content harvest.plant_part.to_s } end end diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb index 710fcd4d4..47244a445 100644 --- a/spec/views/home/_blurb.html.haml_spec.rb +++ b/spec/views/home/_blurb.html.haml_spec.rb @@ -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 'home/_blurb.html.haml', type: "view" do diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb index ecbb74227..cc91976b8 100644 --- a/spec/views/home/_crops.html.haml_spec.rb +++ b/spec/views/home/_crops.html.haml_spec.rb @@ -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 'home/_crops.html.haml', type: "view" do diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb index f131d5b67..76aa434b6 100644 --- a/spec/views/home/_members.html.haml_spec.rb +++ b/spec/views/home/_members.html.haml_spec.rb @@ -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 'home/_members.html.haml', type: "view" do diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb index 4a128f1f6..7b8d6156c 100644 --- a/spec/views/home/_seeds.html.haml_spec.rb +++ b/spec/views/home/_seeds.html.haml_spec.rb @@ -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 'home/_seeds.html.haml', type: "view" do diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb index 6bfc3e6fe..a9979190c 100644 --- a/spec/views/home/_stats.html.haml_spec.rb +++ b/spec/views/home/_stats.html.haml_spec.rb @@ -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 'home/_stats.html.haml', type: "view" do diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb index 190ee7b9f..5e11882fd 100644 --- a/spec/views/home/index_spec.rb +++ b/spec/views/home/index_spec.rb @@ -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 'home/index.html.haml', type: "view" do diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb index badecf8f7..5060fc30d 100644 --- a/spec/views/layouts/_header_spec.rb +++ b/spec/views/layouts/_header_spec.rb @@ -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 'layouts/_header.html.haml', type: "view" do diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb index 805f0298d..151c6fe19 100644 --- a/spec/views/layouts/_meta_spec.rb +++ b/spec/views/layouts/_meta_spec.rb @@ -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 'layouts/_meta.html.haml', type: "view" do diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb index b773cce58..f094ae2c2 100644 --- a/spec/views/layouts/application_spec.rb +++ b/spec/views/layouts/application_spec.rb @@ -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 'layouts/application.html.haml', type: "view" do diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb index ee52b7319..2c8195069 100644 --- a/spec/views/notifications/index.html.haml_spec.rb +++ b/spec/views/notifications/index.html.haml_spec.rb @@ -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 "notifications/index" do diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb index 2830966e1..a7f030f47 100644 --- a/spec/views/notifications/new.html.haml_spec.rb +++ b/spec/views/notifications/new.html.haml_spec.rb @@ -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 "notifications/new" do diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb index 7cf7838c9..14db0448c 100644 --- a/spec/views/notifications/show.html.haml_spec.rb +++ b/spec/views/notifications/show.html.haml_spec.rb @@ -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 "notifications/show" do diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb index 66e81b158..913ea10d2 100644 --- a/spec/views/notifier/notify.html.haml_spec.rb +++ b/spec/views/notifier/notify.html.haml_spec.rb @@ -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 'notifier/notify.html.haml', type: "view" do diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb index 6053de32f..c95f204e2 100644 --- a/spec/views/orders/index.html.haml_spec.rb +++ b/spec/views/orders/index.html.haml_spec.rb @@ -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 "orders/index" do diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb index 32289bfc9..a9f662de9 100644 --- a/spec/views/orders/show.html.haml_spec.rb +++ b/spec/views/orders/show.html.haml_spec.rb @@ -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 "orders/show" do diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb index f1f2eacc5..a52b51a79 100644 --- a/spec/views/photos/edit.html.haml_spec.rb +++ b/spec/views/photos/edit.html.haml_spec.rb @@ -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 "photos/edit" do diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb index 4e1674765..b603de1e6 100644 --- a/spec/views/photos/index.html.haml_spec.rb +++ b/spec/views/photos/index.html.haml_spec.rb @@ -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 "photos/index" do diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb index 2dcb51bfc..e4f24f9e4 100644 --- a/spec/views/photos/new.html.haml_spec.rb +++ b/spec/views/photos/new.html.haml_spec.rb @@ -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 "photos/new" do diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb index 5ca8c31e1..cecb0008b 100644 --- a/spec/views/photos/show.html.haml_spec.rb +++ b/spec/views/photos/show.html.haml_spec.rb @@ -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 "photos/show" do diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb index efc101bc1..7082290c8 100644 --- a/spec/views/places/_map_attribution.html.haml_spec.rb +++ b/spec/views/places/_map_attribution.html.haml_spec.rb @@ -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 "places/_map_attribution.html.haml", type: :view do diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb index 44299c286..f3a3661ae 100644 --- a/spec/views/places/index.html.haml_spec.rb +++ b/spec/views/places/index.html.haml_spec.rb @@ -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 "places/index" do diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb index c5e4cca10..635d06ab9 100644 --- a/spec/views/places/show.html.haml_spec.rb +++ b/spec/views/places/show.html.haml_spec.rb @@ -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 "places/show" do diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb index e871b49d3..683dd6ab0 100644 --- a/spec/views/plant_parts/edit.html.haml_spec.rb +++ b/spec/views/plant_parts/edit.html.haml_spec.rb @@ -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 "plant_parts/edit" do diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb index 73dec883e..65ecf2d63 100644 --- a/spec/views/plant_parts/index.html.haml_spec.rb +++ b/spec/views/plant_parts/index.html.haml_spec.rb @@ -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 "plant_parts/index" do diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb index 31218ee71..b1b3f12ae 100644 --- a/spec/views/plant_parts/new.html.haml_spec.rb +++ b/spec/views/plant_parts/new.html.haml_spec.rb @@ -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 "plant_parts/new" do diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb index bffd0f394..b367a723b 100644 --- a/spec/views/plant_parts/show.html.haml_spec.rb +++ b/spec/views/plant_parts/show.html.haml_spec.rb @@ -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 "plant_parts/show" do diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb index 59d4d832b..692b53173 100644 --- a/spec/views/plantings/_form.html.haml_spec.rb +++ b/spec/views/plantings/_form.html.haml_spec.rb @@ -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 "plantings/_form" do @@ -24,6 +12,7 @@ describe "plantings/_form" do @planting = FactoryBot.create(:planting, garden: @garden, crop: @crop, + owner: @member, planted_at: Date.new(2013, 3, 1)) render end diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb index c37f9947a..b83af0028 100644 --- a/spec/views/plantings/edit.html.haml_spec.rb +++ b/spec/views/plantings/edit.html.haml_spec.rb @@ -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 "plantings/edit" do @@ -28,7 +16,7 @@ describe "plantings/edit" do @garden2 = FactoryBot.create(:garden_a, owner: @member) @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @tomato)) + FactoryBot.create(:planting, garden: @garden, crop: @tomato, owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb index e7831889f..f682d62e9 100644 --- a/spec/views/plantings/index.html.haml_spec.rb +++ b/spec/views/plantings/index.html.haml_spec.rb @@ -1,41 +1,31 @@ -## 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 "plantings/index" do + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:tomato) { FactoryBot.create(:tomato) } + let(:maize) { FactoryBot.create(:maize) } before(:each) do controller.stub(:current_user) { nil } - @member = FactoryBot.create(:member) - @garden = FactoryBot.create(:garden, owner: @member) - @tomato = FactoryBot.create(:tomato) - @maize = FactoryBot.create(:maize) page = 1 per_page = 3 total_entries = 3 plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager| pager.replace([ FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, - owner: @member), + garden: garden, + crop: tomato, + owner: member), FactoryBot.create(:planting, - garden: @garden, - crop: @maize, + garden: garden, + crop: maize, + owner: garden.owner, description: '', planted_at: Time.zone.local(2013, 1, 13)), FactoryBot.create(:planting, - garden: @garden, - crop: @tomato, + garden: garden, + owner: garden.owner, + crop: tomato, planted_at: Time.zone.local(2013, 1, 13), finished_at: Time.zone.local(2013, 1, 20), finished: true) @@ -46,10 +36,10 @@ describe "plantings/index" do end it "renders a list of plantings" do - rendered.should have_content @tomato.name - rendered.should have_content @maize.name - rendered.should have_content @member.login_name - rendered.should have_content @garden.name + rendered.should have_content tomato.name + rendered.should have_content maize.name + rendered.should have_content member.login_name + rendered.should have_content garden.name end it "displays planting time" do @@ -69,14 +59,14 @@ describe "plantings/index" do end it "displays member's name in title" do - assign(:owner, @member) + assign(:owner, member) render - view.content_for(:title).should have_content @member.login_name + view.content_for(:title).should have_content member.login_name end it "displays crop's name in title" do - assign(:crop, @tomato) + assign(:crop, tomato) render - view.content_for(:title).should have_content @tomato.name + view.content_for(:title).should have_content tomato.name end end diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb index 1d15ad5cc..c4a394561 100644 --- a/spec/views/plantings/index.rss.haml_spec.rb +++ b/spec/views/plantings/index.rss.haml_spec.rb @@ -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 'plantings/index.rss.haml' do diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb index 9eb941d1d..6667a05ee 100644 --- a/spec/views/plantings/new.html.haml_spec.rb +++ b/spec/views/plantings/new.html.haml_spec.rb @@ -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 "plantings/new" do @@ -25,7 +13,8 @@ describe "plantings/new" do assign(:planting, FactoryBot.create(:planting, garden: @garden_a, - crop: @crop2)) + crop: @crop2, + owner: @member)) end context "logged in" do diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb index f948ca394..c20f7e909 100644 --- a/spec/views/plantings/show.html.haml_spec.rb +++ b/spec/views/plantings/show.html.haml_spec.rb @@ -1,37 +1,22 @@ -## 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 "plantings/show" do - def create_planting_for(member) - @garden = FactoryBot.create(:garden, owner: @member) - @crop = FactoryBot.create(:tomato) - @planting = assign(:planting, - FactoryBot.create(:planting, garden: @garden, crop: @crop, - planted_from: 'cutting')) + let(:crop) { FactoryBot.create(:tomato) } + let(:member) { FactoryBot.create(:member) } + let(:garden) { FactoryBot.create(:garden, owner: member) } + let(:planting) do + FactoryBot.create(:planting, garden: garden, crop: crop, + owner: garden.owner, + planted_from: 'cutting') end before(:each) do - @member = FactoryBot.create(:member) - controller.stub(:current_user) { @member } - @p = create_planting_for(@member) + assign(:planting, planting) + controller.stub(:current_user) { member } end context 'sunniness' do - before(:each) do - @p = assign(:planting, - FactoryBot.create(:sunny_planting)) - end + let(:planting) { FactoryBot.create(:sunny_planting) } it "shows the sunniness" do render @@ -41,10 +26,7 @@ describe "plantings/show" do end context 'planted from' do - before(:each) do - @p = assign(:planting, FactoryBot.create(:cutting_planting)) - end - + let(:planting) { FactoryBot.create(:cutting_planting) } it "shows planted_from" do render rendered.should have_content 'Planted from:' @@ -52,8 +34,7 @@ describe "plantings/show" do end it "doesn't show planted_from if blank" do - @p.planted_from = '' - @p.save + planting.update(planted_from: '') render rendered.should_not have_content 'Planted from:' rendered.should_not have_content 'cutting' @@ -61,10 +42,10 @@ describe "plantings/show" do end it "shows photos" do - @photo = FactoryBot.create(:photo, owner: @member) - @p.photos << @photo + photo = FactoryBot.create(:photo, owner: member) + planting.photos << photo render - assert_select "img[src='#{@photo.thumbnail_url}']" + assert_select "img[src='#{photo.thumbnail_url}']" end it "shows a link to add photos" do @@ -96,13 +77,12 @@ describe "plantings/show" do context "location set" do before(:each) do - @p.owner.location = 'Greenwich, UK' - @p.owner.save + planting.owner.update(location: 'Greenwich, UK') render end it "shows the member's location in parentheses" do - rendered.should have_content "(#{@p.owner.location})" + rendered.should have_content "(#{planting.owner.location})" end end end diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb index 833970b29..a153995c5 100644 --- a/spec/views/posts/_single.html.haml_spec.rb +++ b/spec/views/posts/_single.html.haml_spec.rb @@ -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 "posts/_single" do diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb index 8bee4298b..48d64a267 100644 --- a/spec/views/posts/edit.html.haml_spec.rb +++ b/spec/views/posts/edit.html.haml_spec.rb @@ -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 "posts/edit" do diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb index 17aab3d47..eeebac8b6 100644 --- a/spec/views/posts/index.html.haml_spec.rb +++ b/spec/views/posts/index.html.haml_spec.rb @@ -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 "posts/index" do diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb index a47b80b48..3d4ec11f2 100644 --- a/spec/views/posts/index.rss.haml_spec.rb +++ b/spec/views/posts/index.rss.haml_spec.rb @@ -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 'posts/index.rss.haml', type: "view" do diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb index 0c788716e..fa344e55b 100644 --- a/spec/views/posts/new.html.haml_spec.rb +++ b/spec/views/posts/new.html.haml_spec.rb @@ -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 "posts/new" do diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb index 97625fa2c..c22c4196f 100644 --- a/spec/views/posts/show.rss.haml_spec.rb +++ b/spec/views/posts/show.rss.haml_spec.rb @@ -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 'posts/show.rss.haml' do diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb index e0d8ebbda..3d60c9e95 100644 --- a/spec/views/products/edit.html.haml_spec.rb +++ b/spec/views/products/edit.html.haml_spec.rb @@ -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 "products/edit" do diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb index cbde70cf1..90e08e2a3 100644 --- a/spec/views/products/index.html.haml_spec.rb +++ b/spec/views/products/index.html.haml_spec.rb @@ -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 "products/index" do diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb index d75741775..336c6bac1 100644 --- a/spec/views/products/new.html.haml_spec.rb +++ b/spec/views/products/new.html.haml_spec.rb @@ -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 "products/new" do diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb index ee529cc71..315d9caae 100644 --- a/spec/views/products/show.html.haml_spec.rb +++ b/spec/views/products/show.html.haml_spec.rb @@ -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 "products/show" do diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb index 9135b8639..a86f67ceb 100644 --- a/spec/views/roles/edit.html.haml_spec.rb +++ b/spec/views/roles/edit.html.haml_spec.rb @@ -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 "roles/edit" do diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb index 54fe35337..e4b28e9ba 100644 --- a/spec/views/roles/index.html.haml_spec.rb +++ b/spec/views/roles/index.html.haml_spec.rb @@ -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 "roles/index" do diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb index a56fce052..1cdce8c41 100644 --- a/spec/views/roles/new.html.haml_spec.rb +++ b/spec/views/roles/new.html.haml_spec.rb @@ -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 "roles/new" do diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb index 03df232ec..56f1cc4fb 100644 --- a/spec/views/roles/show.html.haml_spec.rb +++ b/spec/views/roles/show.html.haml_spec.rb @@ -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 "roles/show" do diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb index abd9b4c62..ecaa2056f 100644 --- a/spec/views/scientific_names/edit.html.haml_spec.rb +++ b/spec/views/scientific_names/edit.html.haml_spec.rb @@ -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 "scientific_names/edit" do diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb index 248ca5be9..4d63ac9e1 100644 --- a/spec/views/scientific_names/index.html.haml_spec.rb +++ b/spec/views/scientific_names/index.html.haml_spec.rb @@ -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 "scientific_names/index" do diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb index f820007a7..0cf5a4205 100644 --- a/spec/views/scientific_names/new.html.haml_spec.rb +++ b/spec/views/scientific_names/new.html.haml_spec.rb @@ -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 "scientific_names/new" do diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb index a12082fa4..b728df2b3 100644 --- a/spec/views/scientific_names/show.html.haml_spec.rb +++ b/spec/views/scientific_names/show.html.haml_spec.rb @@ -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 "scientific_names/show" do diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb index 6822bf961..f450d7065 100644 --- a/spec/views/seeds/edit.html.haml_spec.rb +++ b/spec/views/seeds/edit.html.haml_spec.rb @@ -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 "seeds/edit" do diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb index 7e2b3df88..4df8e526c 100644 --- a/spec/views/seeds/index.rss.haml_spec.rb +++ b/spec/views/seeds/index.rss.haml_spec.rb @@ -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 'seeds/index.rss.haml' do diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb index a05da5b23..5c5cf3ae4 100644 --- a/spec/views/seeds/new.html.haml_spec.rb +++ b/spec/views/seeds/new.html.haml_spec.rb @@ -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 "seeds/new" do diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb index 654d27b0f..975f2baa1 100644 --- a/spec/views/seeds/show.html.haml_spec.rb +++ b/spec/views/seeds/show.html.haml_spec.rb @@ -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 "seeds/show" do diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb index e809782bc..3bd0061d7 100644 --- a/spec/views/shop/index_spec.rb +++ b/spec/views/shop/index_spec.rb @@ -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 'shop/index.html.haml', type: "view" do