mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-14 03:05:59 -04:00
Merge branch 'dev' into awesomecode-rspec/multiplesubjects-7391
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class GardensController < ApplicationController
|
||||
before_action :authenticate_member!, except: %i(index show)
|
||||
before_action :authenticate_member!, except: %i(index show timeline)
|
||||
after_action :expire_homepage, only: %i(create delete)
|
||||
load_and_authorize_resource
|
||||
respond_to :html, :json
|
||||
|
||||
@@ -15,6 +15,12 @@ class Ability
|
||||
can :view_follows, Member
|
||||
can :view_followers, Member
|
||||
|
||||
# Everyone can see the charts
|
||||
can :timeline, Garden
|
||||
can :sunniness, Crop
|
||||
can :planted_from, Crop
|
||||
can :harvested_for, Crop
|
||||
|
||||
# except these, which don't make sense if you're not logged in
|
||||
cannot :read, Notification
|
||||
cannot :read, Authentication
|
||||
|
||||
@@ -46,4 +46,20 @@ describe CropsController do
|
||||
it { expect(response.content_type).to eq("application/rss+xml") }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET charts' do
|
||||
let(:crop) { FactoryBot.create :crop }
|
||||
describe 'sunniness' do
|
||||
before { get :sunniness, crop_id: crop.to_param }
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
describe 'planted_from' do
|
||||
before { get :planted_from, crop_id: crop.to_param }
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
describe 'harvested_for' do
|
||||
before { get :harvested_for, crop_id: crop.to_param }
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,9 +4,8 @@ RSpec.describe GardensController, type: :controller do
|
||||
include Devise::Test::ControllerHelpers
|
||||
let(:valid_params) { { name: 'My second Garden' } }
|
||||
|
||||
let(:garden) { FactoryBot.create :garden }
|
||||
context "when not signed in" do
|
||||
let(:garden) { double('garden') }
|
||||
|
||||
describe 'GET new' do
|
||||
before { get :new, id: garden.to_param }
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
@@ -15,7 +14,10 @@ RSpec.describe GardensController, type: :controller do
|
||||
before { put :create, garden: valid_params }
|
||||
it { expect(response).to redirect_to(new_member_session_path) }
|
||||
end
|
||||
|
||||
describe 'GET timeline' do
|
||||
before { get :timeline, garden_id: garden.to_param }
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
describe 'changing existing records' do
|
||||
before do
|
||||
allow(Garden).to receive(:find).and_return(:garden)
|
||||
@@ -44,6 +46,11 @@ RSpec.describe GardensController, type: :controller do
|
||||
|
||||
let!(:member) { FactoryBot.create(:member) }
|
||||
|
||||
describe 'GET timeline' do
|
||||
before { get :timeline, garden_id: garden.to_param }
|
||||
it { expect(response).to be_success }
|
||||
end
|
||||
|
||||
describe "for another member's garden" do
|
||||
let(:not_my_garden) { double('garden') }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user