-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🥗✨
Agreement
: Test and implement the #create
endpoint
- #1364 This is only for the classic HTML Request <=> Response Cycle. I realized I probably want to do the `#index` Routes before `#create`, or at least get started on the bits to expose adding an `Agreement` in the `Spaces#edit` page.
- Loading branch information
Showing
5 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,51 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Space::AgreementsController do | ||
let(:space) { create(:space) } | ||
|
||
describe "#show" do | ||
subject(:perform_request) do | ||
get polymorphic_path([space, agreement]) | ||
response | ||
end | ||
|
||
let(:space) { agreement.space } | ||
let(:agreement) { create(:space_agreement) } | ||
let(:agreement) { create(:space_agreement, space: space) } | ||
|
||
it { is_expected.to render_template(:show) } | ||
end | ||
|
||
describe "#create" do | ||
subject(:perform_request) do | ||
post polymorphic_path(space.location(child: :agreements)), params: {agreement: agreement_params} | ||
response | ||
end | ||
|
||
let(:agreement_params) { attributes_for(:space_agreement) } | ||
|
||
it { is_expected.to be_not_found } | ||
|
||
context "when signed in as a member" do | ||
before { sign_in(space, person) } | ||
|
||
let(:person) { create(:membership, space: space).member } | ||
|
||
specify do | ||
perform_request | ||
expect(space.reload.agreements).to exist(name: agreement_params[:name], body: agreement_params[:body]) | ||
end | ||
|
||
it { is_expected.to redirect_to(space.location(child: :agreements)) } | ||
end | ||
|
||
context "when the agreement is invalid" do | ||
before { sign_in(space, person) } | ||
|
||
let(:person) { create(:membership, space: space).member } | ||
|
||
let(:agreement_params) { attributes_for(:space_agreement, name: nil) } | ||
|
||
it { is_expected.to render_template(:new) } | ||
specify { expect { perform_request }.not_to change { space.agreements.reload.count } } | ||
end | ||
end | ||
end |