mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-26 02:33:03 -04:00
Merge branch 'dev' into garden-overview
This commit is contained in:
@@ -5,6 +5,7 @@ describe AdminController do
|
||||
|
||||
describe "GET admin/newsletter" do
|
||||
before { get :newsletter }
|
||||
|
||||
describe 'fetches the admin newsletter page' do
|
||||
it { expect(response).to be_success }
|
||||
it { expect(response).to render_template("admin/newsletter") }
|
||||
@@ -12,6 +13,7 @@ describe AdminController do
|
||||
|
||||
describe 'assigns @members' do
|
||||
let!(:m) { FactoryBot.create(:newsletter_recipient_member) }
|
||||
|
||||
it { expect(assigns(:members)).to eq [m] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) do
|
||||
{
|
||||
'Accept' => 'application/vnd.api+json',
|
||||
@@ -37,11 +38,14 @@ RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
'thumbnail' => nil
|
||||
}
|
||||
end
|
||||
|
||||
before { get :index, format: :json }
|
||||
|
||||
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
|
||||
it { expect(matching_planting['attributes']).to eq expected_attributes }
|
||||
it { expect(response.status).to eq 200 }
|
||||
end
|
||||
|
||||
context 'with photo' do
|
||||
let!(:my_planting) { FactoryBot.create(:planting, owner: member, planted_at: '2000-01-01') }
|
||||
|
||||
@@ -65,10 +69,12 @@ RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
}
|
||||
end
|
||||
let(:photo) { FactoryBot.create(:photo, owner: my_planting.owner) }
|
||||
|
||||
before do
|
||||
my_planting.photos << photo
|
||||
get :index, format: :json
|
||||
end
|
||||
|
||||
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
|
||||
it { expect(matching_planting['attributes']).to eq expected_attributes }
|
||||
it { expect(response.status).to eq 200 }
|
||||
|
||||
@@ -3,16 +3,22 @@ require 'rails_helper'
|
||||
describe Charts::CropsController do
|
||||
describe 'GET charts' do
|
||||
let(:crop) { FactoryBot.create :crop }
|
||||
|
||||
describe 'sunniness' do
|
||||
before { get :sunniness, params: { crop_slug: crop.to_param } }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'planted_from' do
|
||||
before { get :planted_from, params: { crop_slug: crop.to_param } }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe 'harvested_for' do
|
||||
before { get :harvested_for, params: { crop_slug: crop.to_param } }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,7 @@ describe Charts::GardensController do
|
||||
context "when not signed in" do
|
||||
describe 'GET timeline' do
|
||||
before { get :timeline, params: { garden_id: garden.to_param } }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
||||
@@ -20,6 +21,7 @@ describe Charts::GardensController do
|
||||
|
||||
describe 'GET timeline' do
|
||||
before { get :timeline, params: { garden_id: garden.to_param } }
|
||||
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,6 +54,7 @@ describe CommentsController do
|
||||
|
||||
describe "GET edit" do
|
||||
let(:post) { FactoryBot.create(:post) }
|
||||
|
||||
before { get :edit, params: { id: comment.to_param } }
|
||||
|
||||
describe "my comment" do
|
||||
|
||||
@@ -9,11 +9,13 @@ RSpec.describe GardensController, type: :controller do
|
||||
context "when not signed in" do
|
||||
describe 'GET new' do
|
||||
before { get :new, params: { id: garden.to_param } }
|
||||
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
|
||||
describe 'PUT create' do
|
||||
before { put :create, params: { garden: valid_params } }
|
||||
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
|
||||
@@ -29,16 +31,19 @@ RSpec.describe GardensController, type: :controller do
|
||||
|
||||
describe 'GET edit' do
|
||||
before { get :edit, params: { id: garden.to_param } }
|
||||
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
|
||||
describe 'POST update' do
|
||||
before { post :update, params: { id: garden.to_param, garden: valid_params } }
|
||||
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
|
||||
describe 'DELETE' do
|
||||
before { delete :destroy, params: { id: garden.to_param, params: { garden: valid_params } } }
|
||||
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
end
|
||||
@@ -63,16 +68,19 @@ RSpec.describe GardensController, type: :controller do
|
||||
|
||||
describe 'GET edit' do
|
||||
before { get :edit, params: { id: not_my_garden.to_param } }
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
end
|
||||
|
||||
describe 'POST update' do
|
||||
before { post :update, params: { id: not_my_garden.to_param, garden: valid_params } }
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
end
|
||||
|
||||
describe 'DELETE' do
|
||||
before { delete :destroy, params: { id: not_my_garden.to_param, params: { garden: valid_params } } }
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,17 +22,20 @@ describe HarvestsController do
|
||||
|
||||
describe "assigns all harvests as @harvests" do
|
||||
before { get :index, params: {} }
|
||||
|
||||
it { expect(assigns(:harvests)).to eq [harvest1, harvest2] }
|
||||
end
|
||||
|
||||
describe "picks up owner from params and shows owner's harvests only" do
|
||||
before { get :index, params: { member_slug: member1.slug } }
|
||||
|
||||
it { expect(assigns(:owner)).to eq member1 }
|
||||
it { expect(assigns(:harvests)).to eq [harvest1] }
|
||||
end
|
||||
|
||||
describe "picks up crop from params and shows the harvests for the crop only" do
|
||||
before { get :index, params: { crop_slug: maize.name } }
|
||||
|
||||
it { expect(assigns(:crop)).to eq maize }
|
||||
it { expect(assigns(:harvests)).to eq [harvest2] }
|
||||
end
|
||||
@@ -49,6 +52,7 @@ describe HarvestsController do
|
||||
|
||||
describe "assigns the requested harvest as @harvest" do
|
||||
before { get :show, params: { id: harvest.to_param } }
|
||||
|
||||
it { expect(assigns(:harvest)).to eq(harvest) }
|
||||
end
|
||||
end
|
||||
@@ -70,6 +74,7 @@ describe HarvestsController do
|
||||
|
||||
describe "assigns the requested harvest as @harvest" do
|
||||
before { get :edit, params: { id: harvest.to_param } }
|
||||
|
||||
it { expect(assigns(:harvest)).to eq(harvest) }
|
||||
end
|
||||
end
|
||||
@@ -84,18 +89,22 @@ describe HarvestsController do
|
||||
|
||||
describe "assigns a newly created harvest as @harvest" do
|
||||
before { post :create, params: { harvest: valid_attributes } }
|
||||
|
||||
it { expect(assigns(:harvest)).to be_a(Harvest) }
|
||||
it { expect(assigns(:harvest)).to be_persisted }
|
||||
end
|
||||
|
||||
describe "redirects to the created harvest" do
|
||||
before { post :create, params: { harvest: valid_attributes } }
|
||||
|
||||
it { expect(response).to redirect_to(Harvest.last) }
|
||||
end
|
||||
|
||||
describe "links to planting" do
|
||||
let(:planting) { FactoryBot.create(:planting, owner_id: member.id, garden: member.gardens.first) }
|
||||
|
||||
before { post :create, params: { harvest: valid_attributes.merge(planting_id: planting.id) } }
|
||||
|
||||
it { expect(Harvest.last.planting.id).to eq(planting.id) }
|
||||
end
|
||||
end
|
||||
@@ -111,6 +120,7 @@ describe HarvestsController do
|
||||
describe "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
before { post :create, params: { harvest: { "crop_id" => "invalid value" } } }
|
||||
|
||||
it { expect(response).to render_template("new") }
|
||||
end
|
||||
end
|
||||
@@ -133,6 +143,7 @@ describe HarvestsController do
|
||||
describe "PUT update" do
|
||||
describe "with valid params" do
|
||||
let(:harvest) { Harvest.create! valid_attributes }
|
||||
|
||||
it "updates the requested harvest" do
|
||||
new_crop = FactoryBot.create :crop
|
||||
expect do
|
||||
@@ -143,11 +154,13 @@ describe HarvestsController do
|
||||
|
||||
describe "assigns the requested harvest as @harvest" do
|
||||
before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } }
|
||||
|
||||
it { expect(assigns(:harvest)).to eq(harvest) }
|
||||
end
|
||||
|
||||
describe "redirects to the harvest" do
|
||||
before { put :update, params: { id: harvest.to_param, harvest: valid_attributes } }
|
||||
|
||||
it { expect(response).to redirect_to(harvest) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ describe LikesController do
|
||||
describe "POST create" do
|
||||
it { expect(response.content_type).to eq "application/json" }
|
||||
before { post :create, params: { post_id: blogpost.id, format: :json } }
|
||||
|
||||
it { expect(Like.last.likeable_id).to eq(blogpost.id) }
|
||||
it { expect(Like.last.likeable_type).to eq('Post') }
|
||||
it { JSON.parse(response.body)["description"] == "1 like" }
|
||||
@@ -26,6 +27,7 @@ describe LikesController do
|
||||
|
||||
describe "DELETE destroy" do
|
||||
before { delete :destroy, params: { id: like.id, format: :json } }
|
||||
|
||||
it { expect(response.content_type).to eq "application/json" }
|
||||
|
||||
describe "un-liking something i liked before" do
|
||||
|
||||
@@ -58,6 +58,7 @@ describe MembersController do
|
||||
describe "GET member's RSS feed" do
|
||||
describe "returns an RSS feed" do
|
||||
before { get :show, params: { slug: @member.to_param }, format: "rss" }
|
||||
|
||||
it { response.should be_success }
|
||||
it { response.should render_template("members/show") }
|
||||
it { response.content_type.should eq("application/rss+xml") }
|
||||
|
||||
@@ -39,6 +39,7 @@ describe PhotosController do
|
||||
|
||||
describe "planting photos" do
|
||||
before(:each) { get :new, params: { 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 }
|
||||
@@ -47,12 +48,14 @@ describe PhotosController do
|
||||
|
||||
describe "harvest photos" do
|
||||
before { get :new, params: { type: "harvest", id: harvest.id } }
|
||||
|
||||
it { assigns(:item).should eq harvest }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
end
|
||||
|
||||
describe "garden photos" do
|
||||
before { get :new, params: { type: "garden", id: garden.id } }
|
||||
|
||||
it { expect(assigns(:item)).to eq garden }
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
end
|
||||
@@ -130,6 +133,7 @@ describe PhotosController do
|
||||
describe "for the second time" do
|
||||
let(:planting) { FactoryBot.create :planting, owner: member }
|
||||
let(:valid_params) { { photo: { flickr_photo_id: 1 }, id: planting.id, type: 'planting' } }
|
||||
|
||||
it "does not add a photo twice" do
|
||||
expect { post :create, params: valid_params }.to change(Photo, :count).by(1)
|
||||
expect { post :create, params: valid_params }.not_to change(Photo, :count)
|
||||
@@ -151,6 +155,7 @@ describe PhotosController do
|
||||
before do
|
||||
post :create, params: { photo: { flickr_photo_id: photo.flickr_photo_id }, type: "harvest", id: harvest.id }
|
||||
end
|
||||
|
||||
it { expect(flash[:alert]).not_to be_present }
|
||||
it { expect(Photo.last.harvests.first).to eq harvest }
|
||||
end
|
||||
|
||||
@@ -26,12 +26,14 @@ describe PlantingsController do
|
||||
|
||||
describe "picks up owner from params and shows owner's plantings only" do
|
||||
before { get :index, params: { member_slug: member1.slug } }
|
||||
|
||||
it { expect(assigns(:owner)).to eq member1 }
|
||||
it { expect(assigns(:plantings)).to eq [planting1] }
|
||||
end
|
||||
|
||||
describe "picks up crop from params and shows the plantings for the crop only" do
|
||||
before { get :index, params: { crop_slug: maize.slug } }
|
||||
|
||||
it { expect(assigns(:crop)).to eq maize }
|
||||
it { expect(assigns(:plantings)).to eq [planting2] }
|
||||
end
|
||||
@@ -40,44 +42,56 @@ describe PlantingsController do
|
||||
describe "GET new" do
|
||||
describe "picks up crop from params" do
|
||||
let(:crop) { FactoryBot.create(:crop) }
|
||||
|
||||
before { get :new, params: { crop_id: crop.id } }
|
||||
|
||||
it { expect(assigns(:crop)).to eq(crop) }
|
||||
end
|
||||
|
||||
describe "doesn't die if no crop specified" do
|
||||
before { get :new, params: {} }
|
||||
|
||||
it { expect(assigns(:crop)).to be_a_new(Crop) }
|
||||
end
|
||||
|
||||
describe "picks up member's garden from params" do
|
||||
let(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
|
||||
before { get :new, params: { garden_id: garden.id } }
|
||||
|
||||
it { expect(assigns(:garden)).to eq(garden) }
|
||||
end
|
||||
|
||||
describe "Doesn't display another member's garden on planting form" do
|
||||
let(:another_member) { FactoryBot.create(:member) } # over-riding member from login_member()
|
||||
let(:garden) { FactoryBot.create(:garden, owner: another_member) }
|
||||
|
||||
before { get :new, params: { garden_id: garden.id } }
|
||||
|
||||
it { expect(assigns(:garden)).not_to eq(garden) }
|
||||
end
|
||||
|
||||
describe "Doesn't display un-approved crops on planting form" do
|
||||
let(:crop) { FactoryBot.create(:crop, approval_status: 'pending') }
|
||||
let!(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
|
||||
before { get :new, params: { crop_id: crop.id } }
|
||||
|
||||
it { expect(assigns(:crop)).not_to eq(crop) }
|
||||
end
|
||||
|
||||
describe "Doesn't display rejected crops on planting form" do
|
||||
let(:crop) { FactoryBot.create(:crop, approval_status: 'rejected', reason_for_rejection: 'nope') }
|
||||
let!(:garden) { FactoryBot.create(:garden, owner: member) }
|
||||
|
||||
before { get :new, params: { crop_id: crop.id } }
|
||||
|
||||
it { expect(assigns(:crop)).not_to eq(crop) }
|
||||
end
|
||||
|
||||
describe "doesn't die if no garden specified" do
|
||||
before { get :new, params: {} }
|
||||
|
||||
it { expect(assigns(:garden)).to be_a_new(Garden) }
|
||||
end
|
||||
|
||||
@@ -89,7 +103,9 @@ describe PlantingsController do
|
||||
|
||||
context 'with parent seed' do
|
||||
let(:seed) { FactoryBot.create :seed, owner: member }
|
||||
|
||||
before { get :new, params: { seed_id: seed.to_param } }
|
||||
|
||||
it { expect(assigns(:seed)).to eq(seed) }
|
||||
end
|
||||
end
|
||||
@@ -97,6 +113,7 @@ describe PlantingsController do
|
||||
describe 'POST :create' do
|
||||
describe "sets the owner automatically" do
|
||||
before { post :create, params: { planting: valid_attributes } }
|
||||
|
||||
it { expect(assigns(:planting).owner).to eq subject.current_member }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,8 +5,10 @@ describe SeedsController do
|
||||
|
||||
describe "GET index" do
|
||||
let(:owner) { FactoryBot.create(:member) }
|
||||
|
||||
describe "picks up owner from params" do
|
||||
before { get :index, params: { member_slug: owner.slug } }
|
||||
|
||||
it { expect(assigns(:owner)).to eq(owner) }
|
||||
end
|
||||
end
|
||||
@@ -22,7 +24,9 @@ describe SeedsController do
|
||||
|
||||
context 'with parent planting' do
|
||||
let(:planting) { FactoryBot.create :planting, owner: owner }
|
||||
|
||||
before { get :new, params: { planting_id: planting.to_param } }
|
||||
|
||||
it { expect(assigns(:planting)).to eq(planting) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,6 +5,7 @@ FactoryBot.define do
|
||||
sender { FactoryBot.create :member }
|
||||
recipient { FactoryBot.create :member }
|
||||
subject { "MyString" }
|
||||
|
||||
body { "MyText" }
|
||||
read { false }
|
||||
post
|
||||
|
||||
@@ -34,6 +34,7 @@ feature "crop wranglers", js: true do
|
||||
|
||||
describe "visiting a crop can see wrangler links" do
|
||||
before { visit crop_path(crops.first) }
|
||||
|
||||
it { expect(page).to have_content 'You are a CROP WRANGLER' }
|
||||
it { expect(page).to have_link 'Edit' }
|
||||
it { expect(page).to have_link 'Delete' }
|
||||
|
||||
@@ -13,6 +13,7 @@ feature "browse crops" do
|
||||
|
||||
context "when the most recently created harvest is not the most recently harvested" do
|
||||
before { FactoryBot.create_list :harvest, 20, crop: tomato, harvested_at: 1.year.ago, created_at: 1.minute.ago }
|
||||
|
||||
let!(:most_recent_harvest) do
|
||||
FactoryBot.create :harvest, crop: tomato, harvested_at: 60.minutes.ago, created_at: 10.minute.ago
|
||||
end
|
||||
@@ -25,6 +26,7 @@ feature "browse crops" do
|
||||
|
||||
context "when the most recently created planting is not the most recently planted" do
|
||||
before { FactoryBot.create_list :planting, 20, crop: tomato, planted_at: 1.year.ago, created_at: 1.minute.ago }
|
||||
|
||||
let!(:most_recent_planting) do
|
||||
FactoryBot.create :planting, crop: tomato, planted_at: 60.minutes.ago, created_at: 10.minute.ago
|
||||
end
|
||||
|
||||
@@ -55,13 +55,16 @@ feature "Gardens" do
|
||||
describe '#show' do
|
||||
describe 'my garden' do
|
||||
before { visit garden_path(garden) }
|
||||
|
||||
it { is_expected.to have_link 'Edit' }
|
||||
it { is_expected.to have_link 'Delete' }
|
||||
it { is_expected.to have_content "Plant something here" }
|
||||
it { is_expected.to have_content "Add photo" }
|
||||
end
|
||||
|
||||
describe "someone else's garden" do
|
||||
before { visit garden_path(other_member_garden) }
|
||||
|
||||
it { is_expected.not_to have_link 'Edit' }
|
||||
it { is_expected.not_to have_link 'Delete' }
|
||||
it { is_expected.not_to have_content "Plant something here" }
|
||||
|
||||
@@ -87,6 +87,7 @@ feature "home page" do
|
||||
|
||||
describe 'should say welcome' do
|
||||
before { visit root_path }
|
||||
|
||||
it { expect(page).to have_content "Welcome to #{ENV['GROWSTUFF_SITE_NAME']}, #{member.login_name}" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -233,6 +233,7 @@ feature "Planting a crop", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
end
|
||||
|
||||
it { expect(page).to have_content "planting was successfully created" }
|
||||
it { expect(page).to have_content "Finished: Yes (no date specified)" }
|
||||
it { expect(page).to have_content "100%" }
|
||||
|
||||
@@ -47,6 +47,7 @@ feature "Seeds", :js, :elasticsearch do
|
||||
click_button "Save"
|
||||
end
|
||||
end
|
||||
|
||||
it { expect(page).to have_content "Successfully added maize seed to your stash" }
|
||||
it { expect(page).to have_content "Quantity: 42" }
|
||||
it { expect(page).to have_content "Days until maturity: 999–1999" }
|
||||
|
||||
@@ -10,10 +10,12 @@ feature "seeds", js: true do
|
||||
|
||||
describe "button on index to edit seed" do
|
||||
let!(:seed) { create :seed, owner: member }
|
||||
|
||||
before do
|
||||
visit seeds_path
|
||||
click_link "edit_seed_glyphicon"
|
||||
end
|
||||
|
||||
it { expect(current_path).to eq edit_seed_path(seed) }
|
||||
it { expect(page).to have_content 'Editing seeds' }
|
||||
end
|
||||
@@ -23,6 +25,7 @@ feature "seeds", js: true do
|
||||
visit root_path
|
||||
click_link "Save seeds"
|
||||
end
|
||||
|
||||
it { expect(current_path).to eq new_seed_path }
|
||||
it { expect(page).to have_content 'Save seeds' }
|
||||
end
|
||||
@@ -32,6 +35,7 @@ feature "seeds", js: true do
|
||||
visit member_seeds_path(member)
|
||||
click_link "View #{member}'s profile >>"
|
||||
end
|
||||
|
||||
it { expect(current_path).to eq member_path(member) }
|
||||
end
|
||||
|
||||
@@ -49,32 +53,39 @@ feature "seeds", js: true do
|
||||
|
||||
describe "delete seeds" do
|
||||
let(:seed) { FactoryBot.create :seed, owner: member }
|
||||
|
||||
before do
|
||||
visit seed_path(seed)
|
||||
click_link 'Delete'
|
||||
end
|
||||
|
||||
it { expect(current_path).to eq seeds_path }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { visit seed_path(seed) }
|
||||
|
||||
describe "view seeds with max and min days until maturity" do
|
||||
let(:seed) { FactoryBot.create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7 }
|
||||
|
||||
it { expect(page).to have_content "Days until maturity: 5–7" }
|
||||
end
|
||||
|
||||
describe "view seeds with only max days until maturity" do
|
||||
let(:seed) { FactoryBot.create :seed, days_until_maturity_max: 7 }
|
||||
|
||||
it { expect(page).to have_content "Days until maturity: 7" }
|
||||
end
|
||||
|
||||
describe "view seeds with only min days until maturity" do
|
||||
let(:seed) { FactoryBot.create :seed, days_until_maturity_min: 5 }
|
||||
|
||||
it { expect(page).to have_content "Days until maturity: 5" }
|
||||
end
|
||||
|
||||
describe "view seeds with neither max nor min days until maturity" do
|
||||
let(:seed) { FactoryBot.create :seed }
|
||||
|
||||
it { expect(page).to have_content "Days until maturity: unknown" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ require 'rails_helper'
|
||||
# end
|
||||
RSpec.describe ButtonsHelper, type: :helper do
|
||||
before { allow(self).to receive(:can?) { true } }
|
||||
|
||||
let(:garden) { FactoryBot.create :garden }
|
||||
let(:planting) { FactoryBot.create :planting }
|
||||
let(:harvest) { FactoryBot.create :harvest }
|
||||
|
||||
@@ -288,6 +288,7 @@ describe Crop do
|
||||
let(:crop2_planting) { crop2.plantings.first }
|
||||
|
||||
let(:member) { FactoryBot.create :member, login_name: 'pikachu' }
|
||||
|
||||
describe 'lists interesting crops' do
|
||||
before do
|
||||
# they need 3+ plantings each to be interesting
|
||||
|
||||
@@ -6,6 +6,7 @@ describe 'member' do
|
||||
|
||||
describe 'should be fetchable from the database' do
|
||||
subject { Member.find(member.id) }
|
||||
|
||||
it { is_expected.to be_an_instance_of Member }
|
||||
it { expect(subject.encrypted_password).not_to be_nil }
|
||||
end
|
||||
|
||||
@@ -332,6 +332,7 @@ describe Planting do
|
||||
context 'photos' do
|
||||
let(:planting) { FactoryBot.create(:planting) }
|
||||
let(:photo) { FactoryBot.create(:photo, owner_id: planting.owner_id) }
|
||||
|
||||
before { planting.photos << photo }
|
||||
|
||||
it 'has a photo' do
|
||||
|
||||
@@ -2,6 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe Post do
|
||||
let(:member) { FactoryBot.create(:member, login_name: 'whinacooper') }
|
||||
|
||||
it_behaves_like "it is likeable"
|
||||
|
||||
it "should have a slug" do
|
||||
|
||||
@@ -154,6 +154,7 @@ describe Seed do
|
||||
let(:seed) { FactoryBot.create :seed }
|
||||
|
||||
before { seed.photos << FactoryBot.create(:photo, owner: seed.owner) }
|
||||
|
||||
it 'is found in has_photos scope' do
|
||||
Seed.has_photos.should include(seed)
|
||||
end
|
||||
@@ -162,6 +163,7 @@ describe Seed do
|
||||
context 'ancestry' do
|
||||
let(:parent_planting) { FactoryBot.create :planting }
|
||||
let(:seed) { FactoryBot.create :seed, parent_planting: parent_planting, owner: parent_planting.owner }
|
||||
|
||||
it "seed has a parent planting" do
|
||||
expect(seed.parent_planting).to eq(parent_planting)
|
||||
end
|
||||
|
||||
@@ -58,11 +58,13 @@ RSpec.describe 'Plantings', type: :request do
|
||||
|
||||
describe '#index' do
|
||||
before { get '/api/v1/crops', params: {}, headers: headers }
|
||||
|
||||
it { expect(subject['data']).to include(crop_encoded_as_json_api) }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get "/api/v1/crops/#{crop.id}", params: {}, headers: 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) }
|
||||
|
||||
@@ -59,11 +59,13 @@ RSpec.describe 'Harvests', type: :request do
|
||||
|
||||
describe '#index' do
|
||||
before { get '/api/v1/harvests', params: {}, headers: headers }
|
||||
|
||||
it { expect(subject['data']).to include(harvest_encoded_as_json_api) }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get "/api/v1/harvests/#{harvest.id}", params: {}, headers: 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) }
|
||||
|
||||
@@ -59,11 +59,13 @@ RSpec.describe 'Members', type: :request do
|
||||
|
||||
describe '#index' do
|
||||
before { get '/api/v1/members', params: {}, headers: headers }
|
||||
|
||||
it { expect(subject['data']).to include(member_encoded_as_json_api) }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get "/api/v1/members/#{member.id}", params: {}, headers: 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) }
|
||||
|
||||
@@ -57,11 +57,13 @@ RSpec.describe 'Photos', type: :request do
|
||||
|
||||
describe '#index' do
|
||||
before { get '/api/v1/photos', params: {}, headers: headers }
|
||||
|
||||
it { expect(subject['data']).to include(photo_encoded_as_json_api) }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get "/api/v1/photos/#{photo.id}", params: {}, headers: 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) }
|
||||
|
||||
@@ -46,11 +46,13 @@ RSpec.describe 'Photos', type: :request do
|
||||
|
||||
describe '#index' do
|
||||
before { get '/api/v1/seeds', params: {}, headers: headers }
|
||||
|
||||
it { expect(subject['data']).to include(seed_encoded_as_json_api) }
|
||||
end
|
||||
|
||||
describe '#show' do
|
||||
before { get "/api/v1/seeds/#{seed.id}", params: {}, headers: 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) }
|
||||
|
||||
@@ -2,6 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe "posts/new" do
|
||||
let(:author) { FactoryBot.create(:member) }
|
||||
|
||||
before(:each) do
|
||||
assign(:post, FactoryBot.create(:post, author: author))
|
||||
# assign(:forum, Forum.new)
|
||||
|
||||
@@ -2,6 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe "posts/show" do
|
||||
subject { rendered }
|
||||
|
||||
let(:author) { FactoryBot.create(:member, login_name: 'mary') }
|
||||
|
||||
before(:each) do
|
||||
|
||||
@@ -2,6 +2,7 @@ require 'rails_helper'
|
||||
|
||||
describe "seeds/show" do
|
||||
let(:seed) { FactoryBot.create(:seed) }
|
||||
|
||||
before(:each) do
|
||||
controller.stub(:current_user) { nil }
|
||||
assign(:seed, seed)
|
||||
|
||||
Reference in New Issue
Block a user