From 5145ead93b392aa68d2561a7a334508993aa8ff2 Mon Sep 17 00:00:00 2001 From: Awesome Code Date: Tue, 12 Mar 2019 22:51:12 +0000 Subject: [PATCH] Auto corrected by following Lint Ruby RSpecEmptyLine --- spec/controllers/comments_controller_spec.rb | 1 + spec/controllers/crops_controller_spec.rb | 8 ++++++++ spec/controllers/likes_controller_spec.rb | 1 + spec/controllers/photos_controller_spec.rb | 3 +++ spec/features/photos/show_photo_spec.rb | 4 ++++ spec/features/signout_spec.rb | 1 + spec/models/crop_spec.rb | 1 + spec/models/photo_spec.rb | 1 + 8 files changed, 20 insertions(+) diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 3454f33f6..07f5ad149 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -36,6 +36,7 @@ describe CommentsController do before { get :new, params: { post_id: post.id } } let(:old_comment) { FactoryBot.create(:comment, post: post) } + it "picks up post from params" do expect(assigns(:post)).to eq(post) end diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb index 112d768cd..b683715a3 100644 --- a/spec/controllers/crops_controller_spec.rb +++ b/spec/controllers/crops_controller_spec.rb @@ -11,11 +11,14 @@ describe CropsController do describe 'fetches the crop wrangler homepage' do context 'anonymous' do before { get :wrangle } + it { is_expected.not_to be_success } end + context 'wrangler' do include_context 'login as wrangler' before { get :wrangle } + it { is_expected.to be_success } it { is_expected.to render_template("crops/wrangle") } it { expect(assigns[:crop_wranglers]).to eq(Role.crop_wranglers) } @@ -28,6 +31,7 @@ describe CropsController do context 'wrangler' do include_context 'login as wrangler' before { get :hierarchy } + it { is_expected.to be_success } it { is_expected.to render_template("crops/hierarchy") } end @@ -55,13 +59,17 @@ describe CropsController do describe 'DELETE destroy' do let!(:crop) { FactoryBot.create :crop } + subject { delete :destroy, params: { slug: crop.to_param } } + context 'not logged in' do it { expect { subject }.not_to change { Crop.count } } end + context 'logged in as member' do it { expect { subject }.not_to change { Crop.count } } end + context 'wrangler' do include_context 'login as wrangler' it { expect { subject }.to change { Crop.count }.by -1 } diff --git a/spec/controllers/likes_controller_spec.rb b/spec/controllers/likes_controller_spec.rb index e16d5669d..516cc368f 100644 --- a/spec/controllers/likes_controller_spec.rb +++ b/spec/controllers/likes_controller_spec.rb @@ -10,6 +10,7 @@ describe LikesController do describe "POST create" do before { post :create, params: { post_id: blogpost.id, format: :json } } + it { expect(response.content_type).to eq "application/json" } it { expect(Like.last.likeable_id).to eq(blogpost.id) } diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 18a4d720a..5b5f5f23c 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -8,7 +8,9 @@ describe PhotosController do describe 'GET index' do describe 'all photos' do let!(:photo) { FactoryBot.create :photo } + before { get :index } + it { expect(assigns(:photos)).to eq [photo] } end @@ -22,6 +24,7 @@ describe PhotosController do planting.photos << crop_photo get :index, params: { crop_slug: crop.to_param } end + it { expect(assigns(:crop)).to eq crop } it { expect(assigns(:photos)).to eq [crop_photo] } end diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb index c2a23f3a7..973aa349a 100644 --- a/spec/features/photos/show_photo_spec.rb +++ b/spec/features/photos/show_photo_spec.rb @@ -15,6 +15,7 @@ feature "show photo page" do planting.photos << photo visit photo_path(photo) end + it { expect(page).to have_link "#{planting.crop.name} planting in #{planting.garden.name} by #{planting.owner}", href: planting_path(planting) @@ -32,6 +33,7 @@ feature "show photo page" do harvest.photos << photo visit photo_path(photo) end + it { expect(page).to have_link "#{harvest.crop.name} harvest by #{harvest.owner}", href: harvest_path(harvest) } it { expect(page).to have_link harvest.crop.name } end @@ -46,6 +48,7 @@ feature "show photo page" do garden.photos << photo visit photo_path(photo) end + it { expect(page).to have_link "garden named \"#{garden.name}\" by #{garden.owner}", href: garden_path(garden) } end end @@ -59,6 +62,7 @@ feature "show photo page" do seed.photos << photo visit photo_path(photo) end + it { expect(page).to have_link "#{seed.crop.name} seeds belonging to #{seed.owner}", href: seed_path(seed) } it { expect(page).to have_link seed.crop.name } end diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb index 2b020a4c2..2ccfd17dc 100644 --- a/spec/features/signout_spec.rb +++ b/spec/features/signout_spec.rb @@ -4,6 +4,7 @@ feature "signout" do let(:member) { create :member } let(:path) {} + scenario "redirect to previous page after signout" do visit crops_path # some random page click_link 'Sign in' diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb index f035bcdbf..bb808fb68 100644 --- a/spec/models/crop_spec.rb +++ b/spec/models/crop_spec.rb @@ -4,6 +4,7 @@ describe Crop do let(:pp2) { FactoryBot.create(:plant_part) } let(:pp1) { FactoryBot.create(:plant_part) } let(:maize) { FactoryBot.create(:maize) } + context 'all fields present' do let(:crop) { FactoryBot.create(:tomato) } diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index c262c473a..920d57f19 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -139,6 +139,7 @@ describe Photo do let(:seed_crop) { FactoryBot.create :crop } let!(:seed) { FactoryBot.create :seed, owner: member, crop: seed_crop } let!(:seed_photo) { FactoryBot.create :photo, owner: member } + before do harvest.photos << harvest_photo planting.photos << planting_photo