From e015eb1c947f5da2d783d11487d76a4e4b90a8cf Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:02:59 +0200 Subject: [PATCH 1/8] show page --- app/views/account/calculators/show.html.erb | 1 + 1 file changed, 1 insertion(+) create mode 100644 app/views/account/calculators/show.html.erb diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb new file mode 100644 index 000000000..9fdb93ec4 --- /dev/null +++ b/app/views/account/calculators/show.html.erb @@ -0,0 +1 @@ +<%= render partial: "shared/under_construction" %> \ No newline at end of file From 0df164a26a2740bd7b641d8b3c873e523cd7bc39 Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:34:18 +0200 Subject: [PATCH 2/8] redirect --- .../account/calculators_controller.rb | 4 ++-- app/views/account/calculators/show.html.erb | 2 +- ....html.erb => _under_construction.html.erb} | 24 +++++++++---------- spec/requests/account/calculators_spec.rb | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename app/views/shared/{under_construction.html.erb => _under_construction.html.erb} (97%) diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index 4a1cd4b6a..526d1c97e 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -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]) @@ -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.slug), notice: t("notifications.calculator_created") else render :new, status: :unprocessable_entity end diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb index 9fdb93ec4..553e9b798 100644 --- a/app/views/account/calculators/show.html.erb +++ b/app/views/account/calculators/show.html.erb @@ -1 +1 @@ -<%= render partial: "shared/under_construction" %> \ No newline at end of file +<%= render "shared/under_construction" %> diff --git a/app/views/shared/under_construction.html.erb b/app/views/shared/_under_construction.html.erb similarity index 97% rename from app/views/shared/under_construction.html.erb rename to app/views/shared/_under_construction.html.erb index 211efc51d..3368a9a4e 100644 --- a/app/views/shared/under_construction.html.erb +++ b/app/views/shared/_under_construction.html.erb @@ -1,12 +1,12 @@ -
-
-
-

<%= t('.title') %>

-

<%= t('.text') %>

-

<%= t('.text_update') %>

-
-
- <%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %> -
-
-
+
+
+
+

<%= t('.title') %>

+

<%= t('.text') %>

+

<%= t('.text_update') %>

+
+
+ <%= image_tag "under_construction.png", alt: t('.alt_text'), class: 'under-construction__img' %> +
+
+
diff --git a/spec/requests/account/calculators_spec.rb b/spec/requests/account/calculators_spec.rb index cb92c8b16..a06af4338 100644 --- a/spec/requests/account/calculators_spec.rb +++ b/spec/requests/account/calculators_spec.rb @@ -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 From 339b220da0e216b71c9ca6b38c99d57d5598fe7a Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:59:54 +0200 Subject: [PATCH 3/8] test fix --- app/controllers/account/calculators_controller.rb | 2 +- spec/requests/calculators_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index 526d1c97e..78f900824 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -31,7 +31,7 @@ def create @calculator = Calculator.new(calculator_params) if @calculator.save - redirect_to account_calculator_path(slug: @calculator.slug), notice: t("notifications.calculator_created") + redirect_to account_calculator_path(slug: @calculator), notice: t("notifications.calculator_created") else render :new, status: :unprocessable_entity end diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index 94c13fc1b..3c626d21a 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -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 + expect(response).to redirect_to(account_calculator_path(slug: calculator)) expect(flash[:notice]).to eq(I18n.t("notifications.calculator_created")) end end From 24454a2bff760595bcb218fd4fa9567390f20fff Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:59:13 +0200 Subject: [PATCH 4/8] deleted variable in test --- spec/requests/calculators_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index 3c626d21a..d45dffae9 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -67,8 +67,7 @@ post account_calculators_path, params: { calculator: valid_attributes } end.to change(Calculator, :count).by(1) - calculator = Calculator.last - expect(response).to redirect_to(account_calculator_path(slug: calculator)) + expect(response).to redirect_to(account_calculator_path(slug: Calculator.last)) expect(flash[:notice]).to eq(I18n.t("notifications.calculator_created")) end end From e057987eafce7d571dea4b2754b69dc434decc75 Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:53:42 +0200 Subject: [PATCH 5/8] using let --- spec/requests/calculators_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index d45dffae9..d956e78f1 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -60,6 +60,7 @@ 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 @@ -67,7 +68,7 @@ post account_calculators_path, params: { calculator: valid_attributes } end.to change(Calculator, :count).by(1) - expect(response).to redirect_to(account_calculator_path(slug: Calculator.last)) + expect(response).to redirect_to(account_calculator_path(slug: last_calculator)) expect(flash[:notice]).to eq(I18n.t("notifications.calculator_created")) end end From fed7fe73a694fef0d18ab43ed1a7d643e6a28edb Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:55:43 +0200 Subject: [PATCH 6/8] cop --- spec/requests/calculators_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/requests/calculators_spec.rb b/spec/requests/calculators_spec.rb index d956e78f1..d6dea7c33 100644 --- a/spec/requests/calculators_spec.rb +++ b/spec/requests/calculators_spec.rb @@ -60,7 +60,7 @@ let(:valid_attributes) { { en_name: "calculator", uk_name: "калькулятор" } } let(:invalid_attributes) { { en_name: "", uk_name: "" } } - let(:last_calculator) {Calculator.last} + let(:last_calculator) { Calculator.last } context "with valid attributes" do it "creates a calculator" do From 30cfb7cd7b095c76dd0b47e4b3de3d354bb3246d Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Mon, 2 Dec 2024 01:08:17 +0200 Subject: [PATCH 7/8] cop --- app/controllers/account/calculators_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/account/calculators_controller.rb b/app/controllers/account/calculators_controller.rb index c8fa7fc64..9a14436cf 100644 --- a/app/controllers/account/calculators_controller.rb +++ b/app/controllers/account/calculators_controller.rb @@ -5,7 +5,6 @@ class Account::CalculatorsController < Account::BaseController before_action :check_constructor_flipper def index - @q = collection.ransack(params[:q]) @calculators = @q.result.page(params[:page]) end From 93b3629d9acf61835d4969581e28de27ccf6d5e0 Mon Sep 17 00:00:00 2001 From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com> Date: Tue, 3 Dec 2024 11:34:48 +0200 Subject: [PATCH 8/8] Update show.html.erb --- app/views/account/calculators/show.html.erb | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/app/views/account/calculators/show.html.erb b/app/views/account/calculators/show.html.erb index 81c695396..553e9b798 100644 --- a/app/views/account/calculators/show.html.erb +++ b/app/views/account/calculators/show.html.erb @@ -1,31 +1 @@ <%= render "shared/under_construction" %> - -