From 0630c36db2679f034953d846588e8c7a3cf8c5ac Mon Sep 17 00:00:00 2001 From: leaf corcoran Date: Tue, 14 Jul 2015 20:07:19 -0700 Subject: [PATCH] new submissions app spec file, add delete specs --- spec/applications/submission_spec.moon | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/applications/submission_spec.moon diff --git a/spec/applications/submission_spec.moon b/spec/applications/submission_spec.moon new file mode 100644 index 00000000..037883e5 --- /dev/null +++ b/spec/applications/submission_spec.moon @@ -0,0 +1,33 @@ +import use_test_server from require "lapis.spec" +import truncate_tables from require "lapis.spec.db" + +import request, request_as from require "spec.helpers" + +factory = require "spec.factory" + +import Users, Submissions, SubmissionLikes, SubmissionTags from require "models" + +describe "applications.submission", -> + use_test_server! + + local submission + + before_each -> + truncate_tables Users, Submissions, SubmissionLikes, SubmissionTags + submission = factory.Submissions! + + it "renders delete submission page", -> + status = request_as submission\get_user!, "/submission/#{submission.id}/delete" + assert.same 200, status + + it "deletes the submission", -> + status, _, headers = request_as submission\get_user!, + "/submission/#{submission.id}/delete", { + post: { + action: "delete" + } + } + + assert.same 302, status + assert.nil Submissions\find submission.id +