Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/controllers/prompts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@ def create
flash[:notice] = ts("Prompt was successfully added.")
redirect_to collection_signup_path(@collection, @challenge_signup)
else
flash[:error] = ts("That prompt would make your overall sign-up invalid, sorry.")
redirect_to edit_collection_signup_path(@collection, @challenge_signup)
render action: :new
end
end

Expand Down
1 change: 1 addition & 0 deletions app/views/prompts/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<!--main content-->
<%= form_for @prompt, :as => :prompt, :url => collection_prompts_path(@collection), :html => {:method => :post} do |form| %>
<%= error_messages_for @prompt %>
<%= render "prompt_form", :form => form, :required => true, :index => @index %>
<%= submit_fieldset form %>
<% end %>
Expand Down
25 changes: 15 additions & 10 deletions spec/controllers/prompts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
it "displays the prompt" do
get :show, params: { collection_id: collection.name, id: prompt.id }
expect(flash[:error]).blank?
expect(response).to have_http_status(200)
expect(response).to have_http_status(:ok)
expect(response).to render_template("prompts/show")
expect(assigns(:prompt)).to eq(prompt)
end
Expand Down Expand Up @@ -117,7 +117,7 @@
let(:user) { Pseud.find(ChallengeSignup.in_collection(open_signup.collection).first.pseud_id).user }
it "should have no errors" do
post :new, params: { collection_id: open_signup.collection.name, prompt_type: "offer" }
expect(response).to have_http_status(200)
expect(response).to have_http_status(:ok)
expect(flash[:error]).blank?
expect(assigns(:index)).to eq(open_signup.offers.count)
end
Expand All @@ -126,10 +126,18 @@

describe "create" do
let(:user) { Pseud.find(ChallengeSignup.in_collection(open_signup.collection).first.pseud_id).user }
it "should have no errors and redirect to the edit page" do
post :create, params: { collection_id: open_signup.collection.name, prompt_type: "offer", prompt: { description: "This is a description." } }
it_redirects_to_simple("#{collection_signups_path(open_signup.collection)}/"\
"#{open_signup.collection.prompts.first.challenge_signup_id}/edit")
it "should have no errors and redirect to the signup page" do
# Delete existing prompt of current user
open_signup.offers.first.destroy
post :create, params: {
collection_id: open_signup.collection.name,
prompt_type: "offer",
prompt: { description: "This is a description." }
}
it_redirects_to_with_notice(
collection_signup_path(open_signup.collection, open_signup),
"Prompt was successfully added."
)
end

context "prompt has tags" do
Expand Down Expand Up @@ -167,10 +175,7 @@
}
}
}
it_redirects_to_with_error(
edit_collection_signup_path(open_signup.collection, open_signup),
"That prompt would make your overall sign-up invalid, sorry."
)
expect(response).to have_http_status(:ok) # no redirect
expect(assigns[:prompt].errors[:base]).to eq(
["^These character tags in your offer are not canonical and cannot be used in this challenge: Sakura Typomoto. To fix this, please ask your challenge moderator to set up a tag set for the challenge. New tags can be added to the tag set manually by the moderator or through open nominations."]
)
Expand Down
Loading