Compare commits

..

1 Commits

Author SHA1 Message Date
Daniel O'Connor
b76cfd3957 Rubocop: RSpec/IncludeExamples 2026-04-23 13:31:16 +00:00
62 changed files with 146 additions and 148 deletions

View File

@@ -108,5 +108,23 @@ jobs:
run: bundle exec rails db:prepare run: bundle exec rails db:prepare
- name: Run tests with test-queue - name: Run rspec (lib)
run: bundle exec test-queue rspec spec -fd run: bundle exec rspec spec/lib/ -fd --fail-fast
- name: Run rspec (services)
run: bundle exec rspec spec/services/ -fd --fail-fast
- name: Run rspec (models)
run: bundle exec rspec spec/models/ -fd --fail-fast
- name: Run rspec (controllers)
run: bundle exec rspec spec/controllers/ -fd --fail-fast
- name: Run rspec (views)
run: bundle exec rspec spec/views/ -fd --fail-fast
- name: Run rspec (routing)
run: bundle exec rspec spec/routing/ -fd --fail-fast
- name: Run rspec (request)
run: bundle exec rspec spec/requests/ -fd --fail-fast

View File

@@ -242,6 +242,12 @@ RSpec/BeforeAfterAll:
Exclude: Exclude:
- 'spec/tasks/import_spec.rb' - 'spec/tasks/import_spec.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
RSpec/ContextMethod:
Exclude:
- 'spec/requests/api/v1/activities_request_spec.rb'
# Offense count: 299 # Offense count: 299
# Configuration parameters: Prefixes, AllowedPatterns. # Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without # Prefixes: when, with, without
@@ -293,6 +299,14 @@ RSpec/EmptyLineAfterExample:
RSpec/ExampleLength: RSpec/ExampleLength:
Max: 27 Max: 27
# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: method_call, block
RSpec/ExpectChange:
Exclude:
- 'spec/models/crop_spec.rb'
# Offense count: 32 # Offense count: 32
RSpec/ExpectInHook: RSpec/ExpectInHook:
Exclude: Exclude:
@@ -320,26 +334,6 @@ RSpec/HooksBeforeExamples:
Exclude: Exclude:
- 'spec/features/crops/creating_a_crop_spec.rb' - 'spec/features/crops/creating_a_crop_spec.rb'
# Offense count: 53
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/IncludeExamples:
Exclude:
- 'spec/features/conversations/index_spec.rb'
- 'spec/features/crops/alternate_name_spec.rb'
- 'spec/features/crops/browse_crops_spec.rb'
- 'spec/features/crops/creating_a_crop_spec.rb'
- 'spec/features/crops/crop_photos_spec.rb'
- 'spec/features/crops/delete_crop_spec.rb'
- 'spec/features/gardens/actions_spec.rb'
- 'spec/features/gardens/adding_gardens_spec.rb'
- 'spec/features/gardens/index_spec.rb'
- 'spec/features/likeable_spec.rb'
- 'spec/features/signout_spec.rb'
- 'spec/models/crop_spec.rb'
- 'spec/support/feature_helpers.rb'
- 'spec/views/photos/show.html.haml_spec.rb'
- 'spec/views/seeds/index.rss.haml_spec.rb'
# Offense count: 37 # Offense count: 37
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. # Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
RSpec/IndexedLet: RSpec/IndexedLet:
@@ -472,6 +466,23 @@ RSpec/VerifiedDoubles:
- 'spec/controllers/gardens_controller_spec.rb' - 'spec/controllers/gardens_controller_spec.rb'
- 'spec/views/devise/shared/_links_spec.rb' - 'spec/views/devise/shared/_links_spec.rb'
# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ResponseMethods.
# ResponseMethods: response, last_response
RSpecRails/HaveHttpStatus:
Exclude:
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
- 'spec/controllers/harvests_controller_spec.rb'
- 'spec/controllers/likes_controller_spec.rb'
- 'spec/requests/harvests_spec.rb'
# Offense count: 17
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Inferences.
RSpecRails/InferredSpecType:
Enabled: false
# Offense count: 30 # Offense count: 30
# Configuration parameters: Database. # Configuration parameters: Database.
# SupportedDatabases: mysql, postgresql # SupportedDatabases: mysql, postgresql
@@ -591,6 +602,7 @@ Rails/RedundantActiveRecordAllMethod:
- 'app/controllers/scientific_names_controller.rb' - 'app/controllers/scientific_names_controller.rb'
- 'spec/features/members/deletion_spec.rb' - 'spec/features/members/deletion_spec.rb'
- 'spec/features/percy/percy_spec.rb' - 'spec/features/percy/percy_spec.rb'
- 'spec/models/harvest_spec.rb'
# Offense count: 5 # Offense count: 5
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
@@ -672,6 +684,12 @@ Rails/WhereEquals:
- 'app/models/harvest.rb' - 'app/models/harvest.rb'
- 'app/models/planting.rb' - 'app/models/planting.rb'
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Rails/WhereMissing:
Exclude:
- 'app/controllers/crops_controller.rb'
# Offense count: 3 # Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
Rails/WhereRange: Rails/WhereRange:
@@ -728,6 +746,13 @@ Style/FloatDivision:
Exclude: Exclude:
- 'app/models/concerns/predict_planting.rb' - 'app/models/concerns/predict_planting.rb'
# Offense count: 22
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Enabled: false
# Offense count: 2 # Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all). # This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream: Style/GlobalStdStream:

View File

@@ -196,7 +196,6 @@ group :test do
gem 'rails-controller-testing' gem 'rails-controller-testing'
gem "rspec-rebound" gem "rspec-rebound"
gem 'selenium-webdriver' gem 'selenium-webdriver'
gem 'test-queue'
gem 'timecop' gem 'timecop'
gem 'vcr' gem 'vcr'
end end

View File

@@ -719,7 +719,6 @@ GEM
unicode-display_width (>= 1.1.1, < 4) unicode-display_width (>= 1.1.1, < 4)
terser (1.2.7) terser (1.2.7)
execjs (>= 0.3.0, < 3) execjs (>= 0.3.0, < 3)
test-queue (0.11.1)
thor (1.5.0) thor (1.5.0)
thread_safe (0.3.6) thread_safe (0.3.6)
tilt (2.7.0) tilt (2.7.0)
@@ -874,7 +873,6 @@ DEPENDENCIES
sitemap_generator sitemap_generator
sprockets (< 4) sprockets (< 4)
terser terser
test-queue
timecop timecop
unicorn unicorn
validate_url validate_url

View File

@@ -160,7 +160,7 @@ class CropsController < ApplicationController
when 'youtube' when 'youtube'
Crop.approved.where(en_youtube_url: [nil, '']).order(plantings_count: :desc) Crop.approved.where(en_youtube_url: [nil, '']).order(plantings_count: :desc)
when 'alternate_names' when 'alternate_names'
Crop.approved.where.missing(:alternate_names).order(plantings_count: :desc) Crop.approved.left_joins(:alternate_names).where(alternate_names: { id: nil }).order(plantings_count: :desc)
when 'wikidata' when 'wikidata'
crops_with_wikidata = Crop.joins(:scientific_names).where.not(scientific_names: { wikidata_id: nil }).distinct crops_with_wikidata = Crop.joins(:scientific_names).where.not(scientific_names: { wikidata_id: nil }).distinct
Crop.approved.where.not(id: crops_with_wikidata).order(plantings_count: :desc) Crop.approved.where.not(id: crops_with_wikidata).order(plantings_count: :desc)

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 6.0 upgrade. # This file contains migration options to ease your Rails 6.0 upgrade.

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
# This migration comes from active_storage (originally 20180723000244) # This migration comes from active_storage (originally 20180723000244)
class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0] class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0]
def up def up

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddFieldsToCrops < ActiveRecord::Migration[5.2] class AddFieldsToCrops < ActiveRecord::Migration[5.2]
def change def change
add_column :crops, :row_spacing, :integer add_column :crops, :row_spacing, :integer

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class PopulateCropFieldsFromOpenfarmData < ActiveRecord::Migration[5.2] class PopulateCropFieldsFromOpenfarmData < ActiveRecord::Migration[5.2]
def up def up
Crop.find_each do |crop| Crop.find_each do |crop|

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddSocialMediaToMembers < ActiveRecord::Migration[6.0] class AddSocialMediaToMembers < ActiveRecord::Migration[6.0]
def change def change
add_column :members, :website_url, :string add_column :members, :website_url, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class RenameOtherHandleToOtherUrlInMembers < ActiveRecord::Migration[6.0] class RenameOtherHandleToOtherUrlInMembers < ActiveRecord::Migration[6.0]
def change def change
rename_column :members, :other_handle, :other_url rename_column :members, :other_handle, :other_url

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class CreateGardenCollaborators < ActiveRecord::Migration[7.2] class CreateGardenCollaborators < ActiveRecord::Migration[7.2]
def change def change
create_table :garden_collaborators do |t| create_table :garden_collaborators do |t|

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class CreateAustralianFoodClassificationData < ActiveRecord::Migration[5.2] class CreateAustralianFoodClassificationData < ActiveRecord::Migration[5.2]
def change def change
create_table :australian_food_classification_data do |t| create_table :australian_food_classification_data do |t|

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class MakeNotificationsPolymorphic < ActiveRecord::Migration[6.1] class MakeNotificationsPolymorphic < ActiveRecord::Migration[6.1]
def change def change
add_column :notifications, :notifiable_type, :string add_column :notifications, :notifiable_type, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class ChangeCommentsPolymorphic < ActiveRecord::Migration[7.2] class ChangeCommentsPolymorphic < ActiveRecord::Migration[7.2]
def change def change
add_column :comments, :commentable_type, :string add_column :comments, :commentable_type, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddSourceToSeeds < ActiveRecord::Migration[7.2] class AddSourceToSeeds < ActiveRecord::Migration[7.2]
def change def change
add_column :seeds, :source, :string add_column :seeds, :source, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddIndexesCrops < ActiveRecord::Migration[7.2] class AddIndexesCrops < ActiveRecord::Migration[7.2]
def change def change
add_index :alternate_names, :crop_id add_index :alternate_names, :crop_id

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddOverallRatingPlantings < ActiveRecord::Migration[7.2] class AddOverallRatingPlantings < ActiveRecord::Migration[7.2]
def change def change
add_column :plantings, :overall_rating, :integer add_column :plantings, :overall_rating, :integer

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddEnYoutubeUrlToCrops < ActiveRecord::Migration[7.2] class AddEnYoutubeUrlToCrops < ActiveRecord::Migration[7.2]
def change def change
add_column :crops, :en_youtube_url, :string add_column :crops, :en_youtube_url, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
# This migration creates the `versions` table for the Version class. # This migration creates the `versions` table for the Version class.
# All other migrations PT provides are optional. # All other migrations PT provides are optional.
class CreateVersions < ActiveRecord::Migration[7.2] class CreateVersions < ActiveRecord::Migration[7.2]

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
# This migration adds the optional `object_changes` column, in which PaperTrail # This migration adds the optional `object_changes` column, in which PaperTrail
# will store the `changes` diff for each update event. See the readme for # will store the `changes` diff for each update event. See the readme for
# details. # details.

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
class AddPublicFoodKeyToCrops < ActiveRecord::Migration[5.2] class AddPublicFoodKeyToCrops < ActiveRecord::Migration[5.2]
def change def change
add_column :crops, :public_food_key, :string add_column :crops, :public_food_key, :string

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
require 'csv' require 'csv'
namespace :import do namespace :import do

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe Api::V1::PlantingsController do RSpec.describe Api::V1::PlantingsController, type: :controller do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let!(:member) { create(:member) } let!(:member) { create(:member) }
@@ -42,7 +42,7 @@ RSpec.describe Api::V1::PlantingsController do
it { expect(matching_planting).to include('id' => my_planting.id.to_s) } it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
it { expect(matching_planting['attributes']).to eq expected_attributes } it { expect(matching_planting['attributes']).to eq expected_attributes }
it { expect(response).to have_http_status :ok } it { expect(response.status).to eq 200 }
end end
context 'with photo' do context 'with photo' do
@@ -81,7 +81,7 @@ RSpec.describe Api::V1::PlantingsController do
it { expect(matching_planting).to include('id' => my_planting.id.to_s) } it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
it { expect(matching_planting['attributes']).to eq expected_attributes } it { expect(matching_planting['attributes']).to eq expected_attributes }
it { expect(response).to have_http_status :ok } it { expect(response.status).to eq 200 }
end end
end end
end end

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe GardenTypesController do RSpec.describe GardenTypesController, type: :controller do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:valid_params) { { name: 'My second GardenType' } } let(:valid_params) { { name: 'My second GardenType' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe GardensController do RSpec.describe GardensController, type: :controller do
include Devise::Test::ControllerHelpers include Devise::Test::ControllerHelpers
let(:valid_params) { { name: 'My second Garden' } } let(:valid_params) { { name: 'My second Garden' } }

View File

@@ -51,7 +51,7 @@ describe HarvestsController, :search do
describe "generates a csv" do describe "generates a csv" do
before { get :index, format: "csv" } before { get :index, format: "csv" }
it { expect(response).to have_http_status :ok } it { expect(response.status).to eq 200 }
end end
end end

View File

@@ -19,7 +19,7 @@ describe LikesController do
it { JSON.parse(response.body)["description"] == "1 like" } it { JSON.parse(response.body)["description"] == "1 like" }
describe "Liking someone else's post" do describe "Liking someone else's post" do
it { expect(response).to have_http_status(:created) } it { expect(response.code).to eq('201') }
end end
end end
@@ -29,14 +29,14 @@ describe LikesController do
it { expect(response.content_type).to eq "application/json; charset=utf-8" } it { expect(response.content_type).to eq "application/json; charset=utf-8" }
describe "un-liking something i liked before" do describe "un-liking something i liked before" do
it { expect(response).to have_http_status(:ok) } it { expect(response.code).to eq('200') }
it { JSON.parse(response.body)["description"] == "0 likes" } it { JSON.parse(response.body)["description"] == "0 likes" }
end end
describe "Deleting someone else's like" do describe "Deleting someone else's like" do
let(:like) { create(:like) } let(:like) { create(:like) }
it { expect(response).to have_http_status(:forbidden) } it { expect(response.code).to eq('403') }
it { JSON.parse(response.body)["error"] == "Unable to like" } it { JSON.parse(response.body)["error"] == "Unable to like" }
end end
end end

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :garden_collaborator do factory :garden_collaborator do
garden garden

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
RSpec.feature 'Creating a recurring activity' do RSpec.feature 'Creating a recurring activity' do

View File

@@ -18,7 +18,7 @@ describe "Conversations", :js do
click_link 'Inbox' click_link 'Inbox'
end end
include_examples 'is accessible' it_behaves_like 'is accessible'
it { expect(page).to have_content 'something i want to say' } it { expect(page).to have_content 'something i want to say' }
it { page.percy_snapshot(page, name: 'conversations#index') } it { page.percy_snapshot(page, name: 'conversations#index') }

View File

@@ -83,23 +83,23 @@ describe "Alternate names", :js do
end end
context 'Anonymous' do context 'Anonymous' do
include_examples 'show alt names' it_behaves_like 'show alt names'
end end
context 'Signed in member' do context 'Signed in member' do
include_context 'signed in member' include_context 'signed in member'
include_examples 'show alt names' it_behaves_like 'show alt names'
end end
context 'Crop wrangler' do context 'Crop wrangler' do
include_context 'signed in crop wrangler' include_context 'signed in crop wrangler'
include_examples 'show alt names' it_behaves_like 'show alt names'
include_examples 'edit alt names' it_behaves_like 'edit alt names'
end end
context 'Admin' do context 'Admin' do
include_context 'signed in admin' include_context 'signed in admin'
include_examples 'show alt names' it_behaves_like 'show alt names'
include_examples 'edit alt names' it_behaves_like 'edit alt names'
end end
end end

View File

@@ -34,25 +34,25 @@ describe "browse crops", :search do
end end
context 'anon' do context 'anon' do
include_examples 'shows crops' it_behaves_like 'shows crops'
it { expect(page).to have_no_link "Add New Crop" } it { expect(page).to have_no_link "Add New Crop" }
end end
context 'member' do context 'member' do
include_context 'signed in member' include_context 'signed in member'
include_examples 'shows crops' it_behaves_like 'shows crops'
include_examples 'add new crop' it_behaves_like 'add new crop'
end end
context 'wrangler' do context 'wrangler' do
include_context 'signed in crop wrangler' include_context 'signed in crop wrangler'
include_examples 'shows crops' it_behaves_like 'shows crops'
include_examples 'add new crop' it_behaves_like 'add new crop'
end end
context 'admin' do context 'admin' do
include_context 'signed in admin' include_context 'signed in admin'
include_examples 'shows crops' it_behaves_like 'shows crops'
include_examples 'add new crop' it_behaves_like 'add new crop'
end end
end end

View File

@@ -33,7 +33,7 @@ describe "Crop", :js do
shared_examples 'request crop' do shared_examples 'request crop' do
describe "requesting a crop with multiple scientific and alternate name" do describe "requesting a crop with multiple scientific and alternate name" do
include_examples 'fill in form' it_behaves_like 'fill in form'
before do before do
within "form#new_crop" do within "form#new_crop" do
fill_in "request_notes", with: "This is the Philippine national flower." fill_in "request_notes", with: "This is the Philippine national flower."
@@ -50,7 +50,7 @@ describe "Crop", :js do
shared_examples 'create crop' do shared_examples 'create crop' do
describe "creating a crop with multiple scientific and alternate name" do describe "creating a crop with multiple scientific and alternate name" do
include_examples 'fill in form' it_behaves_like 'fill in form'
before do before do
click_button "Save" click_button "Save"
end end
@@ -69,16 +69,16 @@ describe "Crop", :js do
context 'member' do context 'member' do
include_context 'signed in member' include_context 'signed in member'
include_examples 'request crop' it_behaves_like 'request crop'
end end
context 'crop wrangler' do context 'crop wrangler' do
include_context 'signed in crop wrangler' include_context 'signed in crop wrangler'
include_examples 'create crop' it_behaves_like 'create crop'
end end
context 'admin' do context 'admin' do
include_context 'signed in admin' include_context 'signed in admin'
include_examples 'create crop' it_behaves_like 'create crop'
end end
end end

View File

@@ -59,17 +59,17 @@ describe "crop detail page", :js, :search do
context "when signed in" do context "when signed in" do
include_context 'signed in member' include_context 'signed in member'
include_examples "shows photos" it_behaves_like "shows photos"
end end
context "when signed in as photos owner" do context "when signed in as photos owner" do
include_context 'signed in member' include_context 'signed in member'
let(:member) { owner_member } let(:member) { owner_member }
include_examples "shows photos" it_behaves_like "shows photos"
end end
context "when not signed in" do context "when not signed in" do
include_examples "shows photos" it_behaves_like "shows photos"
end end
end end

View File

@@ -27,11 +27,11 @@ describe "Delete crop spec" do
context "As a crop wrangler" do context "As a crop wrangler" do
include_context 'signed in crop wrangler' include_context 'signed in crop wrangler'
include_examples 'delete crop' it_behaves_like 'delete crop'
end end
context 'admin' do context 'admin' do
include_context 'signed in admin' include_context 'signed in admin'
include_examples 'delete crop' it_behaves_like 'delete crop'
end end
end end

View File

@@ -25,7 +25,7 @@ describe "Gardens" do
context 'my gardens' do context 'my gardens' do
before { visit gardens_path(member_slug: member.slug) } before { visit gardens_path(member_slug: member.slug) }
include_examples "has buttons bar at top" it_behaves_like "has buttons bar at top"
context 'with actions menu expanded' do context 'with actions menu expanded' do
before { click_link 'Actions' } before { click_link 'Actions' }
@@ -43,13 +43,13 @@ describe "Gardens" do
context 'all gardens' do context 'all gardens' do
before { visit gardens_path } before { visit gardens_path }
include_examples "has buttons bar at top" it_behaves_like "has buttons bar at top"
end end
context "other member's garden" do context "other member's garden" do
before { visit gardens_path(member_slug: create(:member).slug) } before { visit gardens_path(member_slug: create(:member).slug) }
include_examples "has buttons bar at top" it_behaves_like "has buttons bar at top"
describe 'does not show actions on other member garden' do describe 'does not show actions on other member garden' do
it { is_expected.to have_no_link 'Actions' } it { is_expected.to have_no_link 'Actions' }
end end

View File

@@ -8,7 +8,7 @@ describe "Gardens", :js do
include_context 'signed in member' include_context 'signed in member'
before { visit new_garden_path } before { visit new_garden_path }
include_examples 'is accessible' it_behaves_like 'is accessible'
it "displays required and optional fields properly" do it "displays required and optional fields properly" do
expect(page).to have_css ".required", text: "Name" expect(page).to have_css ".required", text: "Name"

View File

@@ -14,7 +14,7 @@ describe "Gardens#index", :js do
visit member_gardens_path(member_slug: member.slug) visit member_gardens_path(member_slug: member.slug)
end end
include_examples 'is accessible' it_behaves_like 'is accessible'
it "displays each of the gardens" do it "displays each of the gardens" do
member.gardens.each do |garden| member.gardens.each do |garden|

View File

@@ -58,13 +58,13 @@ describe 'Likeable', :js, :search do
describe 'photos#index' do describe 'photos#index' do
let(:path) { photos_path } let(:path) { photos_path }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
describe 'photos#show' do describe 'photos#show' do
let(:path) { photo_path(photo) } let(:path) { photo_path(photo) }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
describe 'crops#show' do describe 'crops#show' do
@@ -74,7 +74,7 @@ describe 'Likeable', :js, :search do
before { planting.photos << photo } before { planting.photos << photo }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
end end
@@ -82,27 +82,27 @@ describe 'Likeable', :js, :search do
let(:like_count_class) { ".post-#{post.id} .like-count" } let(:like_count_class) { ".post-#{post.id} .like-count" }
let(:path) { post_path(post) } let(:path) { post_path(post) }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
describe 'activities' do describe 'activities' do
let(:like_count_class) { ".activity-#{activity.id} .like-count" } let(:like_count_class) { ".activity-#{activity.id} .like-count" }
let(:path) { activity_path(activity) } let(:path) { activity_path(activity) }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
describe 'plantings' do describe 'plantings' do
let(:like_count_class) { ".planting-#{planting.id} .like-count" } let(:like_count_class) { ".planting-#{planting.id} .like-count" }
let(:path) { planting_path(planting) } let(:path) { planting_path(planting) }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
describe 'harvests' do describe 'harvests' do
let(:like_count_class) { ".harvest-#{harvest.id} .like-count" } let(:like_count_class) { ".harvest-#{harvest.id} .like-count" }
let(:path) { harvest_path(harvest) } let(:path) { harvest_path(harvest) }
include_examples 'object can be liked' it_behaves_like 'object can be liked'
end end
end end

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe 'Test with visual testing', :js do describe 'Test with visual testing', :js, type: :feature do
# Use the same random seed every time so our random data is the same # Use the same random seed every time so our random data is the same
# on every run, so doesn't trigger percy to see changes # on every run, so doesn't trigger percy to see changes
before { Faker::Config.random = Random.new(42) } before { Faker::Config.random = Random.new(42) }

View File

@@ -34,11 +34,11 @@ describe "signout" do
end end
describe 'after signout, redirect to signin page if page needs authentication' do describe 'after signout, redirect to signin page if page needs authentication' do
include_examples "sign-in redirects", "/plantings/new" it_behaves_like "sign-in redirects", "/plantings/new"
include_examples "sign-in redirects", "/harvests/new" it_behaves_like "sign-in redirects", "/harvests/new"
include_examples "sign-in redirects", "/posts/new" it_behaves_like "sign-in redirects", "/posts/new"
include_examples "sign-in redirects", "/gardens/new" it_behaves_like "sign-in redirects", "/gardens/new"
include_examples "sign-in redirects", "/seeds/new" it_behaves_like "sign-in redirects", "/seeds/new"
end end
it 'photos' do it 'photos' do

View File

@@ -12,7 +12,7 @@ require 'rails_helper'
# end # end
# end # end
# end # end
RSpec.describe ButtonsHelper do RSpec.describe ButtonsHelper, type: :helper do
before { allow(self).to receive(:can?).and_return(true) } before { allow(self).to receive(:can?).and_return(true) }
let(:garden) { create(:garden) } let(:garden) { create(:garden) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe EventHelper do RSpec.describe EventHelper, type: :helper do
subject { resolve_model(event) } subject { resolve_model(event) }
let(:planting) { create(:planting) } let(:planting) { create(:planting) }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe CropCompanion do RSpec.describe CropCompanion, type: :model do
it 'has a crop' do it 'has a crop' do
cc = described_class.new cc = described_class.new
cc.crop_a = create :tomato cc.crop_a = create :tomato

View File

@@ -154,7 +154,7 @@ describe Crop do
it { expect(crop.default_photo).to eq photo } it { expect(crop.default_photo).to eq photo }
include_examples 'has default photo' it_behaves_like 'has default photo'
end end
context 'with a harvest photo' do context 'with a harvest photo' do
@@ -165,7 +165,7 @@ describe Crop do
it { expect(crop.default_photo).to eq photo } it { expect(crop.default_photo).to eq photo }
include_examples 'has default photo' it_behaves_like 'has default photo'
context 'and planting photo' do context 'and planting photo' do
let(:planting) { create(:planting, crop:) } let(:planting) { create(:planting, crop:) }
@@ -554,7 +554,7 @@ describe Crop do
end end
it "destroys companion links" do it "destroys companion links" do
expect { crop_a.destroy }.to change(CropCompanion, :count).from(2).to(0) expect { crop_a.destroy }.to change { CropCompanion.count }.from(2).to(0)
end end
end end

View File

@@ -144,7 +144,7 @@ describe Harvest do
it 'lists most recent harvests first' do it 'lists most recent harvests first' do
@h1 = create(:harvest, created_at: 1.day.ago) @h1 = create(:harvest, created_at: 1.day.ago)
@h2 = create(:harvest, created_at: 1.hour.ago) @h2 = create(:harvest, created_at: 1.hour.ago)
expect(described_class.order(created_at: :desc)).to eq [@h2, @h1] expect(described_class.all.order(created_at: :desc)).to eq [@h2, @h1]
end end
end end

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Activities' do RSpec.describe 'Activities', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:member) { create(:member) } let(:member) { create(:member) }
@@ -60,7 +60,7 @@ RSpec.describe 'Activities' do
end end
end end
describe '#update' do context '#update' do
let(:params) do let(:params) do
{ {
'data' => { 'data' => {

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Crops' do RSpec.describe 'Crops', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Gardens' do RSpec.describe 'Gardens', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Harvests' do RSpec.describe 'Harvests', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Members' do RSpec.describe 'Members', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Photos' do RSpec.describe 'Photos', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Plantings' do RSpec.describe 'Plantings', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe 'Seeds' do RSpec.describe 'Seeds', type: :request do
subject { JSON.parse response.body } subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } } let(:headers) { { 'Accept' => 'application/vnd.api+json' } }

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe "GardenTypes" do RSpec.describe "GardenTypes", type: :request do
describe "GET /garden_types" do describe "GET /garden_types" do
it "works! (now write some real specs)" do it "works! (now write some real specs)" do
get garden_types_path get garden_types_path

View File

@@ -6,7 +6,7 @@ describe "Harvests" do
describe "GET /harvests" do describe "GET /harvests" do
it "works! (now write some real specs)" do it "works! (now write some real specs)" do
get harvests_path get harvests_path
expect(response).to have_http_status :ok expect(response.status).to be 200
end end
end end
end end

View File

@@ -14,17 +14,17 @@ module FeatureHelpers
shared_context 'signed in member' do shared_context 'signed in member' do
let(:member) { create(:member) } let(:member) { create(:member) }
include_examples 'sign in' it_behaves_like 'sign in'
end end
shared_context 'signed in crop wrangler' do shared_context 'signed in crop wrangler' do
let(:member) { create(:crop_wrangling_member) } let(:member) { create(:crop_wrangling_member) }
include_examples 'sign in' it_behaves_like 'sign in'
end end
shared_context 'signed in admin' do shared_context 'signed in admin' do
let(:member) { create(:admin_member) } let(:member) { create(:admin_member) }
include_examples 'sign in' it_behaves_like 'sign in'
end end
shared_context 'sign in' do shared_context 'sign in' do

View File

@@ -1,5 +1,3 @@
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
require 'rake' require 'rake'

View File

@@ -58,7 +58,7 @@ describe "photos/show" do
render render
end end
include_examples "photo data renders" it_behaves_like "photo data renders"
it "has a delete button" do it "has a delete button" do
assert_select "a[href='#{photo_path(@photo)}']" assert_select "a[href='#{photo_path(@photo)}']"
@@ -71,8 +71,8 @@ describe "photos/show" do
render render
end end
include_examples "photo data renders" it_behaves_like "photo data renders"
include_examples "No links to change data" it_behaves_like "No links to change data"
end end
context "not signed in" do context "not signed in" do
@@ -81,8 +81,8 @@ describe "photos/show" do
render render
end end
include_examples "photo data renders" it_behaves_like "photo data renders"
include_examples "No links to change data" it_behaves_like "No links to change data"
end end
context "CC-licensed photo" do context "CC-licensed photo" do

View File

@@ -2,7 +2,7 @@
require 'rails_helper' require 'rails_helper'
describe "places/_map_attribution.html.haml" do describe "places/_map_attribution.html.haml", type: :view do
before do before do
render render
end end

View File

@@ -31,7 +31,7 @@ describe 'seeds/index.rss.haml', :search do
render render
end end
include_examples 'displays seed in rss feed' it_behaves_like 'displays seed in rss feed'
it 'shows RSS feed title' do it 'shows RSS feed title' do
expect(rendered).to have_content "Recent seeds from all members" expect(rendered).to have_content "Recent seeds from all members"
@@ -60,6 +60,6 @@ describe 'seeds/index.rss.haml', :search do
expect(rendered).to have_content "Recent seeds from #{seed.owner}" expect(rendered).to have_content "Recent seeds from #{seed.owner}"
end end
include_examples 'displays seed in rss feed' it_behaves_like 'displays seed in rss feed'
end end
end end