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 3 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 @@
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 @@ -15,14 +15,14 @@
end

def new
@calculator = Calculator.new

Check warning on line 18 in app/controllers/account/calculators_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/calculators_controller.rb#L18

Added line #L18 was not covered by tests

@calculator.fields.build
@calculator.formulas.build

Check warning on line 21 in app/controllers/account/calculators_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/calculators_controller.rb#L20-L21

Added lines #L20 - L21 were not covered by tests
end

def edit
@calculator = resource

Check warning on line 25 in app/controllers/account/calculators_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/calculators_controller.rb#L25

Added line #L25 was not covered by tests

collect_fields_for_form
end
Expand All @@ -31,14 +31,14 @@
@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
end

def update
@calculator = resource

Check warning on line 41 in app/controllers/account/calculators_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/account/calculators_controller.rb#L41

Added line #L41 was not covered by tests

if updater
redirect_to edit_account_calculator_path(slug: @calculator), notice: t("notifications.calculator_updated")
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 @@ -67,7 +67,8 @@
post account_calculators_path, params: { calculator: valid_attributes }
end.to change(Calculator, :count).by(1)

expect(response).to redirect_to(account_calculators_path)
calculator = Calculator.last
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну що це таке? Я вже не один раз казав, що ми НІКОЛИ не використовуємо змінні у тестах

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