Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

976 redirect to calculator page after creation #980

Merged
Show file tree
Hide file tree
Changes from 6 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
4 changes: 2 additions & 2 deletions app/controllers/account/calculators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Account::CalculatorsController < Account::BaseController
load_and_authorize_resource

def index
render "shared/under_construction" unless Rails.env.local?
render partial: "shared/under_construction" unless Rails.env.local?

@q = collection.ransack(params[:q])
@calculators = @q.result.page(params[:page])
Expand All @@ -31,7 +31,7 @@ def create
@calculator = Calculator.new(calculator_params)

if @calculator.save
redirect_to account_calculators_path, notice: t("notifications.calculator_created")
redirect_to account_calculator_path(slug: @calculator), notice: t("notifications.calculator_created")
else
render :new, status: :unprocessable_entity
end
Expand Down
1 change: 1 addition & 0 deletions app/views/account/calculators/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render "shared/under_construction" %>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<section class="under-construction">
<div class="under-construction__wrapper">
<div class="under-construction__content">
<h1 class="under-construction__title"><%= t('.title') %></h1>
<p class="under-construction__text"><%= t('.text') %></p>
<p class="under-construction__text"><%= t('.text_update') %></p>
</div>
<div class="under-construction__img-box">
<%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %>
</div>
</div>
</section>
<section class="under-construction">
<div class="under-construction__wrapper">
<div class="under-construction__content">
<h1 class="under-construction__title"><%= t('.title') %></h1>
<p class="under-construction__text"><%= t('.text') %></p>
<p class="under-construction__text"><%= t('.text_update') %></p>
</div>
<div class="under-construction__img-box">
<%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %>
</div>
</div>
</section>
2 changes: 1 addition & 1 deletion spec/requests/account/calculators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
it "renders the 'under_construction' template" do
get account_calculators_path

expect(response).to render_template("shared/under_construction")
expect(response).to render_template("shared/_under_construction")
end
end

Expand Down
3 changes: 2 additions & 1 deletion spec/requests/calculators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@

let(:valid_attributes) { { en_name: "calculator", uk_name: "калькулятор" } }
let(:invalid_attributes) { { en_name: "", uk_name: "" } }
let(:last_calculator) { Calculator.last }

context "with valid attributes" do
it "creates a calculator" do
expect do
post account_calculators_path, params: { calculator: valid_attributes }
end.to change(Calculator, :count).by(1)

expect(response).to redirect_to(account_calculators_path)
expect(response).to redirect_to(account_calculator_path(slug: last_calculator))
expect(flash[:notice]).to eq(I18n.t("notifications.calculator_created"))
end
end
Expand Down