generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zer-153 Add price category from UI to controller (#249)
* 153 task * Rspec update * Update Rspec * Rspec update * Rspec update * Fix rework * New test for diapers controller, default choose in view * Update navigation slim file * Javascript syntax failure resolve * Remove unnecessary check on js file * feature test for dropdown product category * Default value check on controller * Calculator view conflict resolve * Conflict resolve fix * Use rubocop changes * Tabs in slim and right id using * feature flag activating in feature test * Right rspec tests for controller * Search by product enters between tests * Rubocop changes * Id bias in js file * Removed the extra assignment on js * Update by Single Responsibility Principe * Use rubocop changes * Code cleaning * Use rubocop changes * Product price factory testing * Delete rspec for factory * Update diaper_calculators_spec.rb * Update constants with freeze * Obvious product price factory * Constants, freezes, traits in diaper_calculator and specs * Constants conflict resolve * Move constants to spec/rails_helper.rb * Move constants to controller * Use Rubocop change * Remove findings and split the default test * One more forgoten split
- Loading branch information
Showing
10 changed files
with
157 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FactoryBot.define do | ||
factory :product_price do | ||
association :product, title: "diaper", id: 1 | ||
trait :LOW do | ||
category { :LOW } | ||
price { 4.99 } | ||
end | ||
trait :MEDIUM do | ||
category { :MEDIUM } | ||
price { 6.36 } | ||
end | ||
trait :HIGH do | ||
category { :HIGH } | ||
price { 8.21 } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
FactoryBot.define do | ||
factory :product_type do | ||
title { 'Title' } | ||
title { 'hygiene' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
BUDGETARY_OPTION = 'budgetary' | ||
MEDIUM_OPTION = 'medium' | ||
PREMIUM_OPTION = 'premium' | ||
|
||
describe 'product category dropdown list', js: true do | ||
let(:calculator) { create(:calculator) } | ||
before do | ||
FeatureFlag.get('feature_budget_category').activate | ||
visit '/calculator' | ||
find(:select, 'product_category') | ||
has_select?('product_category', with_options: [BUDGETARY_OPTION, MEDIUM_OPTION, PREMIUM_OPTION]) | ||
end | ||
|
||
it 'default product category' do | ||
expect(page).to have_select('product_category', selected: MEDIUM_OPTION) | ||
end | ||
|
||
it 'custom product category selected' do | ||
select(BUDGETARY_OPTION, from: 'product_category') | ||
expect(page).to have_select('product_category', selected: BUDGETARY_OPTION) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Product, type: :model do | ||
describe 'factory' do | ||
context 'product prices factory not nil' do | ||
it 'low' do | ||
expect(create(:product_price, :LOW)).not_to eq(nil) | ||
end | ||
it 'medium' do | ||
expect(create(:product_price, :MEDIUM)).not_to eq(nil) | ||
end | ||
it 'high' do | ||
expect(create(:product_price, :HIGH)).not_to eq(nil) | ||
end | ||
end | ||
end | ||
end |