Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add expected compensation developer (#108)
* Add and install money-rails gem * Add monetized compensation fields to developers * Add monetize fields to developer * Add compensation input fields for developer * Show salary and hourly rate if present. * Update money config with proper defaults These settings are the new defaults, stops the deprecation warnings. * Remove money gem and use integers for amount * Rebased with main and add viewcomponents * Add tests for the amount and compensation components * Add min - max compensation fields. Renamed expected_ to preferred_ as well * add $ in form instead of USD * rename component to preferred and update min /max * Add suffix for hourly (hr) or annually (annual) * Fix linting errors * Fix linting errors part 2 * Rename test to proper component name * making sure tests are passing * Use 1 migration for the compensation fields * refactor compensation view_components * Update form layout with ranges side by side * Move migration after latest from main * Max rate/salary must be higher than min * Copy edits * Allow nil to avoid nil-to-float comparison Co-authored-by: Joe Masilotti <joe@masilotti.com>
- Loading branch information
1 parent
8e2d06b
commit 8600ca1
Showing
14 changed files
with
179 additions
and
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -348,4 +348,4 @@ RUBY VERSION | ||
| ruby 3.0.2p107 | ||
|
|
||
| BUNDLED WITH | ||
| 2.2.27 | ||
| 2.2.31 | ||
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,3 @@ | ||
| <dd class="flex mt-1 text-sm text-gray-900"> | ||
| <%= amounts.join(" - ") %> /<%= suffix -%> | ||
| </dd> |
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,18 @@ | ||
| class CompensationAmountComponent < ApplicationComponent | ||
| attr_reader :amount_range, :suffix | ||
|
|
||
| def initialize(amount_range:, suffix:) | ||
| @amount_range = amount_range | ||
| @suffix = suffix | ||
| end | ||
|
|
||
| def amounts | ||
| amount_range.map do |amount| | ||
| helpers.number_to_currency(helpers.number_to_human(amount, format: "%n%u", units: {thousand: "K"}), precision: 0) | ||
| end | ||
| end | ||
|
|
||
| def render? | ||
| amount_range.present? | ||
| 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,7 @@ | ||
| <div class="sm:col-span-1"> | ||
| <dt class="text-sm font-medium text-gray-500"> | ||
| Preferred compensation | ||
| </dt> | ||
| <%= render CompensationAmountComponent.new(amount_range: developer.preferred_hourly_rate_range, suffix: "hr") %> | ||
| <%= render CompensationAmountComponent.new(amount_range: developer.preferred_salary_range, suffix: "year") %> | ||
| </div> |
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,11 @@ | ||
| class PreferredCompensationComponent < ApplicationComponent | ||
| attr_reader :developer | ||
|
|
||
| def initialize(developer) | ||
| @developer = developer | ||
| end | ||
|
|
||
| def render? | ||
| developer.preferred_hourly_rate_range.present? || developer.preferred_salary_range.present? | ||
| 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
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,8 @@ | ||
| class AddPreferredCompensationFieldsToDevelopers < ActiveRecord::Migration[7.0] | ||
| def change | ||
| add_column :developers, :preferred_min_hourly_rate, :integer | ||
| add_column :developers, :preferred_max_hourly_rate, :integer | ||
| add_column :developers, :preferred_min_salary, :integer | ||
| add_column :developers, :preferred_max_salary, :integer | ||
| end | ||
| end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,18 @@ | ||
| require "test_helper" | ||
|
|
||
| class CompensationAmountComponentTest < ViewComponent::TestCase | ||
| test "doesn't render without amounts" do | ||
| render_inline CompensationAmountComponent.new(amount_range: [], suffix: nil) | ||
| assert_no_select "*" | ||
| end | ||
|
|
||
| test "renders with amount range in USD" do | ||
| render_inline CompensationAmountComponent.new(amount_range: [150, 250], suffix: "hr") | ||
| assert_text "$150 - $250 /hr" | ||
| end | ||
|
|
||
| test "renders with only 1 value" do | ||
| render_inline CompensationAmountComponent.new(amount_range: [250], suffix: "hr") | ||
| assert_text "$250 /hr" | ||
| 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,24 @@ | ||
| require "test_helper" | ||
|
|
||
| class PreferredCompensationComponentTest < ViewComponent::TestCase | ||
| setup do | ||
| @developer = developers(:available) | ||
| end | ||
|
|
||
| test "doesn't render without an expected compensation" do | ||
| render_inline(PreferredCompensationComponent.new(@developer)) | ||
| assert_no_select "*" | ||
| end | ||
|
|
||
| test "renders hourly rate if provided" do | ||
| @developer.preferred_min_hourly_rate = 150 | ||
| render_inline(PreferredCompensationComponent.new(@developer)) | ||
| assert_text "$150" | ||
| end | ||
|
|
||
| test "renders yearly salary if provided" do | ||
| @developer.preferred_min_salary = 250000 | ||
| render_inline(PreferredCompensationComponent.new(@developer)) | ||
| assert_text "$250K" | ||
| 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