Skip to content
Open

Rubocop #4257

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/factories/comments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

FactoryBot.define do
factory :comment do
association :commentable, factory: :post
commentable factory: %i(post)
author
sequence(:body) { |n| "OMG LOL #{n}" }
# because our commenters are more polite than YouTube's
Expand Down
2 changes: 2 additions & 0 deletions spec/factories/garden_collaborators.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

FactoryBot.define do
factory :garden_collaborator do
garden
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

body { "MyText" }
read { false }
association :notifiable, factory: :post
notifiable factory: %i(post)

factory :no_email_notification do
recipient { FactoryBot.create(:no_email_notifications_member) }
Expand Down
2 changes: 1 addition & 1 deletion spec/features/conversations/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
click_link 'Inbox'
end

include_examples 'is accessible'
it_behaves_like 'is accessible'

it { expect(page).to have_content 'something i want to say' }
it { page.percy_snapshot(page, name: 'conversations#index') }
Expand Down
12 changes: 6 additions & 6 deletions spec/features/crops/alternate_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,23 @@
end

context 'Anonymous' do
include_examples 'show alt names'
it_behaves_like 'show alt names'
end

context 'Signed in member' do
include_context 'signed in member'
include_examples 'show alt names'
it_behaves_like 'show alt names'
end

context 'Crop wrangler' do
include_context 'signed in crop wrangler'
include_examples 'show alt names'
include_examples 'edit alt names'
it_behaves_like 'show alt names'
it_behaves_like 'edit alt names'
end

context 'Admin' do
include_context 'signed in admin'
include_examples 'show alt names'
include_examples 'edit alt names'
it_behaves_like 'show alt names'
it_behaves_like 'edit alt names'
end
end
14 changes: 7 additions & 7 deletions spec/features/crops/browse_crops_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
end

context 'anon' do
include_examples 'shows crops'
it_behaves_like 'shows crops'
it { expect(page).to have_no_link "Add New Crop" }
end

context 'member' do
include_context 'signed in member'
include_examples 'shows crops'
include_examples 'add new crop'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
end

context 'wrangler' do
include_context 'signed in crop wrangler'
include_examples 'shows crops'
include_examples 'add new crop'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
end

context 'admin' do
include_context 'signed in admin'
include_examples 'shows crops'
include_examples 'add new crop'
it_behaves_like 'shows crops'
it_behaves_like 'add new crop'
end
end
10 changes: 5 additions & 5 deletions spec/features/crops/creating_a_crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

shared_examples 'request crop' 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
within "form#new_crop" do
fill_in "request_notes", with: "This is the Philippine national flower."
Expand All @@ -50,7 +50,7 @@

shared_examples 'create crop' 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
click_button "Save"
end
Expand All @@ -69,16 +69,16 @@

context 'member' do
include_context 'signed in member'
include_examples 'request crop'
it_behaves_like 'request crop'
end

context 'crop wrangler' do
include_context 'signed in crop wrangler'
include_examples 'create crop'
it_behaves_like 'create crop'
end

context 'admin' do
include_context 'signed in admin'
include_examples 'create crop'
it_behaves_like 'create crop'
end
end
6 changes: 3 additions & 3 deletions spec/features/crops/crop_photos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@

context "when signed in" do
include_context 'signed in member'
include_examples "shows photos"
it_behaves_like "shows photos"
end

context "when signed in as photos owner" do
include_context 'signed in member'
let(:member) { owner_member }

include_examples "shows photos"
it_behaves_like "shows photos"
end

context "when not signed in" do
include_examples "shows photos"
it_behaves_like "shows photos"
end
end
4 changes: 2 additions & 2 deletions spec/features/crops/delete_crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

context "As a crop wrangler" do
include_context 'signed in crop wrangler'
include_examples 'delete crop'
it_behaves_like 'delete crop'
end

context 'admin' do
include_context 'signed in admin'
include_examples 'delete crop'
it_behaves_like 'delete crop'
end
end
6 changes: 3 additions & 3 deletions spec/features/gardens/actions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
context 'my gardens' do
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
before { click_link 'Actions' }
Expand All @@ -43,13 +43,13 @@
context 'all gardens' do
before { visit gardens_path }

include_examples "has buttons bar at top"
it_behaves_like "has buttons bar at top"
end

context "other member's garden" do
before { visit gardens_path(member_slug: FactoryBot.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
it { is_expected.to have_no_link 'Actions' }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/gardens/adding_gardens_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include_context 'signed in member'
before { visit new_garden_path }

include_examples 'is accessible'
it_behaves_like 'is accessible'

it "displays required and optional fields properly" do
expect(page).to have_selector ".required", text: "Name"
Expand Down
2 changes: 1 addition & 1 deletion spec/features/gardens/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
visit member_gardens_path(member_slug: member.slug)
end

include_examples 'is accessible'
it_behaves_like 'is accessible'

it "displays each of the gardens" do
member.gardens.each do |garden|
Expand Down
2 changes: 1 addition & 1 deletion spec/features/harvests/harvesting_a_crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

within "form#new_harvest" do
choose plant_part.name
fill_in "When?", with: Time.new(2014, 6, 15)
fill_in "When?", with: Time.zone.local(2014, 6, 15)
fill_in "How many?", with: 42
fill_in "Weighing (in total)", with: 42
fill_in "Notes", with: "It's killer."
Expand Down
14 changes: 7 additions & 7 deletions spec/features/likeable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def like_count_class
describe 'photos#index' do
let(:path) { photos_path }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end

describe 'photos#show' do
let(:path) { photo_path(photo) }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end

describe 'crops#show' do
Expand All @@ -74,35 +74,35 @@ def like_count_class

before { planting.photos << photo }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end
end

describe 'posts' do
let(:like_count_class) { ".post-#{post.id} .like-count" }
let(:path) { post_path(post) }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end

describe 'activities' do
let(:like_count_class) { ".activity-#{activity.id} .like-count" }
let(:path) { activity_path(activity) }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end

describe 'plantings' do
let(:like_count_class) { ".planting-#{planting.id} .like-count" }
let(:path) { planting_path(planting) }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end

describe 'harvests' do
let(:like_count_class) { ".harvest-#{harvest.id} .like-count" }
let(:path) { harvest_path(harvest) }

include_examples 'object can be liked'
it_behaves_like 'object can be liked'
end
end
2 changes: 1 addition & 1 deletion spec/features/members/deletion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
end

describe 'member exists but is marked deleted' do
subject { Member.all.find(member.id) }
subject { Member.find(member.id) }

it { expect(subject).to eq member }
it { expect(subject.discarded?).to be true }
Expand Down
10 changes: 5 additions & 5 deletions spec/features/signout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
end

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"
it_behaves_like "sign-in redirects", "/plantings/new"
it_behaves_like "sign-in redirects", "/harvests/new"
it_behaves_like "sign-in redirects", "/posts/new"
it_behaves_like "sign-in redirects", "/gardens/new"
it_behaves_like "sign-in redirects", "/seeds/new"
end

it 'photos' do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@

it { expect(crop.default_photo).to eq photo }

include_examples 'has default photo'
it_behaves_like 'has default photo'
end

context 'with a harvest photo' do
Expand All @@ -165,7 +165,7 @@

it { expect(crop.default_photo).to eq photo }

include_examples 'has default photo'
it_behaves_like 'has default photo'

context 'and planting photo' do
let(:planting) { FactoryBot.create(:planting, crop:) }
Expand Down
4 changes: 2 additions & 2 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/features/shared_examples/**/*.rb")].sort.each { |f| require f }
Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f }
Rails.root.glob("spec/features/shared_examples/**/*.rb").sort.each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/v1/activities_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'rails_helper'

RSpec.describe 'Activities', type: :request do
subject { JSON.parse response.body }
subject { response.parsed_body }

let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:activity) { FactoryBot.create(:activity, garden: create(:garden), planting: create(:planting)) }
Expand Down
6 changes: 3 additions & 3 deletions spec/support/feature_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ def select_from_autocomplete(select)

shared_context 'signed in member' do
let(:member) { FactoryBot.create(:member) }
include_examples 'sign in'
it_behaves_like 'sign in'
end

shared_context 'signed in crop wrangler' do
let(:member) { FactoryBot.create(:crop_wrangling_member) }
include_examples 'sign in'
it_behaves_like 'sign in'
end

shared_context 'signed in admin' do
let(:member) { FactoryBot.create(:admin_member) }
include_examples 'sign in'
it_behaves_like 'sign in'
end

shared_context 'sign in' do
Expand Down
10 changes: 5 additions & 5 deletions spec/views/photos/show.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
render
end

include_examples "photo data renders"
it_behaves_like "photo data renders"

it "has a delete button" do
assert_select "a[href='#{photo_path(@photo)}']"
Expand All @@ -71,8 +71,8 @@
render
end

include_examples "photo data renders"
include_examples "No links to change data"
it_behaves_like "photo data renders"
it_behaves_like "No links to change data"
end

context "not signed in" do
Expand All @@ -81,8 +81,8 @@
render
end

include_examples "photo data renders"
include_examples "No links to change data"
it_behaves_like "photo data renders"
it_behaves_like "No links to change data"
end

context "CC-licensed photo" do
Expand Down
Loading
Loading