mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-30 03:36:23 -04:00
81 lines
2.2 KiB
Ruby
81 lines
2.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
require 'custom_matchers'
|
|
|
|
describe "Gardens" do
|
|
context 'logged in' do
|
|
subject { page }
|
|
|
|
include_context 'signed in member'
|
|
let(:garden) { member.gardens.first }
|
|
let(:other_member_garden) { create(:garden) }
|
|
|
|
describe '#index' do
|
|
shared_examples "has buttons bar at top" do
|
|
it "has buttons bar at top" do
|
|
within '.layout-nav' do
|
|
expect(subject).to have_link 'Add a garden'
|
|
expect(subject).to have_link 'My gardens'
|
|
expect(subject).to have_link "Everyone's gardens"
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'my gardens' do
|
|
before { visit gardens_path(member_slug: member.slug) }
|
|
|
|
it_behaves_like "has buttons bar at top"
|
|
|
|
context 'with actions menu expanded' do
|
|
before { click_link 'Actions' }
|
|
|
|
it "has actions on garden" do
|
|
expect(subject).to have_link 'Plant something here'
|
|
expect(subject).to have_link 'Mark as inactive'
|
|
expect(subject).to have_link 'Edit'
|
|
expect(subject).to have_link 'Add photo'
|
|
expect(subject).to have_link 'Delete'
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'all gardens' do
|
|
before { visit gardens_path }
|
|
|
|
it_behaves_like "has buttons bar at top"
|
|
end
|
|
|
|
context "other member's garden" do
|
|
before { visit gardens_path(member_slug: create(:member).slug) }
|
|
|
|
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
|
|
end
|
|
end
|
|
|
|
describe '#show' do
|
|
describe 'my garden' do
|
|
before { visit garden_path(garden) }
|
|
|
|
context 'with actions menu expanded' do
|
|
before { click_link 'Actions' }
|
|
|
|
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
|
|
end
|
|
|
|
describe "someone else's garden" do
|
|
before { visit garden_path(other_member_garden) }
|
|
|
|
it { is_expected.to have_no_link 'Actions' }
|
|
end
|
|
end
|
|
end
|
|
end
|