-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update state to archived_with_draft when archived form is updated
- Loading branch information
1 parent
b39b1f5
commit 7c1f2b0
Showing
3 changed files
with
30 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,6 +215,8 @@ | |
end | ||
|
||
describe "#update" do | ||
let(:form) { create :form } | ||
|
||
it "when no forms exists for an id, returns 404 an error" do | ||
put form_path(id: 999), as: :json | ||
expect(response).to have_http_status(:not_found) | ||
|
@@ -223,22 +225,37 @@ | |
end | ||
|
||
it "when given an valid id and params, updates DB and returns 200" do | ||
form1 = create :form | ||
put form_path(form1), params: { submission_email: "[email protected]" }, as: :json | ||
put form_path(form), params: { submission_email: "[email protected]" }, as: :json | ||
expect(response).to have_http_status(:ok) | ||
expect(response.headers["Content-Type"]).to eq("application/json") | ||
expect(json_body).to include(submission_email: "[email protected]") | ||
expect(form1.reload.submission_email).to eq("[email protected]") | ||
expect(form.reload.submission_email).to eq("[email protected]") | ||
end | ||
|
||
it "ignores created_at" do | ||
form1 = create :form | ||
expect { put form_path(form1), params: { created_at: "2023-01-11T16:22:22.661+00:00" }, as: :json }.not_to(change { form1.reload.created_at }) | ||
expect { put form_path(form), params: { created_at: "2023-01-11T16:22:22.661+00:00" }, as: :json }.not_to(change { form.reload.created_at }) | ||
end | ||
|
||
it "ignores updated_at" do | ||
form1 = create :form | ||
expect { put form_path(form1), params: { updated_at: "2023-01-11T16:22:22.661+00:00" }, as: :json }.not_to(change { form1.reload.updated_at }) | ||
expect { put form_path(form), params: { updated_at: "2023-01-11T16:22:22.661+00:00" }, as: :json }.not_to(change { form.reload.updated_at }) | ||
end | ||
|
||
context "when form is live" do | ||
let(:form) { create(:form, :live) } | ||
|
||
it "updates form state to live_with_draft" do | ||
put form_path(form), params: { submission_email: "[email protected]" }, as: :json | ||
expect(form.reload.state).to eq("live_with_draft") | ||
end | ||
end | ||
|
||
context "when form is archived" do | ||
let(:form) { create(:form, :archived) } | ||
|
||
it "updates form state to archived_with_draft" do | ||
put form_path(form), params: { submission_email: "[email protected]" }, as: :json | ||
expect(form.reload.state).to eq("archived_with_draft") | ||
end | ||
end | ||
end | ||
|
||
|