Files
growstuff/spec/controllers/photo_associations_controller_spec.rb
Daniel O'Connor d1f754a288 Rubocop
2022-11-08 00:23:38 +10:30

47 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
describe PhotoAssociationsController do
login_member
describe "destroy" do
let(:valid_params) do
{
id: harvest.id,
type: 'harvest',
photo_id: photo.id
}
end
before { photo.harvests << harvest }
describe "my harvest my photo" do
let(:harvest) { FactoryBot.create(:harvest, owner: member) }
let(:photo) { FactoryBot.create(:photo, owner: member) }
it "removes link" do
expect { delete :destroy, params: valid_params }.to change { photo.harvests.count }.by(-1)
end
end
describe "another member's harvest from another member's photo" do
let(:harvest) { FactoryBot.create(:harvest, owner: photo.owner) }
let(:photo) { FactoryBot.create(:photo) }
it do
expect do
delete :destroy, params: valid_params
rescue StandardError
nil
end.not_to change(photo.harvests, :count)
end
it do
delete :destroy, params: valid_params
expect(response).to have_http_status(:not_found)
end
end
end
end