-
Notifications
You must be signed in to change notification settings - Fork 10
Add list of calculators #1046
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
base: develop
Are you sure you want to change the base?
Add list of calculators #1046
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 1034-api-for-calc #1046 +/- ##
=====================================================
+ Coverage 99.02% 99.05% +0.02%
=====================================================
Files 71 74 +3
Lines 1128 1158 +30
=====================================================
+ Hits 1117 1147 +30
Misses 11 11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d41e95f to
4697448
Compare
| @@ -0,0 +1,13 @@ | |||
| class Api::V2::CalculatorsController < Api::V2::ApplicationController | |||
| def index | |||
| calculators = collection.order_by_name(params[:name]) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можливо варто запермітити параметри?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну це ж не всі параметри передаються
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
але до речі та, давай краще запермітим
| let!(:calculator1) { create(:calculator, en_name: "Calculator_1", uk_name: "Калькулятор_1", en_notes: "Note_1", uk_notes: "Опис_1") } | ||
| let!(:calculator2) { create(:calculator, en_name: "Calculator_2", uk_name: "Калькулятор_2", en_notes: "Note_2", uk_notes: "Опис_2") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила!
| get "/en/api/v2/calculators.json" | ||
|
|
||
| expect(response).to be_successful | ||
| json = response.parsed_body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use local variables in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила!
| get "/en/api/v2/calculators.json", params: { name: "desc" } | ||
|
|
||
| expect(response).to be_successful | ||
| json = response.parsed_body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила!
| @@ -0,0 +1,13 @@ | |||
| class Api::V2::CalculatorsController < Api::V2::ApplicationController | |||
| def index | |||
| calculators = collection.order_by_name(params[:name]) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну це ж не всі параметри передаються
| @@ -0,0 +1,14 @@ | |||
| class CalculatorsSerializer < ApplicationService | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила
app/models/calculator.rb
Outdated
| } | ||
| validates :color, format: { with: /\A#[0-9a-fA-F]{6}\z/ } | ||
|
|
||
| scope :order_by_name, ->(params) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| scope :order_by_name, ->(params) { | |
| scope :order_by_name, ->(order_direction) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ага
| @@ -0,0 +1,13 @@ | |||
| class Api::V2::CalculatorsController < Api::V2::ApplicationController | |||
| def index | |||
| calculators = collection.order_by_name(params[:name]) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
але до речі та, давай краще запермітим
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ага
| let(:attribute_without_locale) { "color" } | ||
|
|
||
| context "when current locale column exists" do | ||
| it "returns the column name for the current locale" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one expect per example please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Виправила
Checklist
What was done aside from the main task as a part of this PR?
Changes
Added an index action to CalculatorsController, which:
What is the current behavior?
Currently the list is not available via API
What is the expected behavior?
The API should return a JSON list of calculators with name and notes, sorted by localized name