Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add in ability to convert rps -> rpd; rework layouts
- Loading branch information
1 parent
5b5aea9
commit 3d763e1
Showing
7 changed files
with
47 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
module Merb | ||
module HomeHelper | ||
|
||
def show_conversion_message(convert_to) | ||
conversion_string = if convert_to == 'rpd' | ||
"reqs/sec is #{@answer} reqs/day" | ||
else | ||
"reqs/day is #{@answer} reqs/sec" | ||
end | ||
"#{h params[:requests_per]} #{conversion_string}" | ||
end | ||
end | ||
end # Merb |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
%h2 Convert to: | ||
= form :action => '/home/rps_calc' do | ||
%input{:name => 'rpd', :size => 40} | ||
=submit 'submit' | ||
= radio_group :convert_to, [{:value => :rps, :label => 'reqs/sec'}, {:value => :rpd, :label => 'reqs/day'}] | ||
%p | ||
= show_conversion_message(params[:convert_to]) | ||
%p | ||
%input{:name => 'requests_per', :size => 40} | ||
= submit 'submit' |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
|
||
Requests per day -> Requests per second: | ||
|
||
= partial :rps |
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 |
---|---|---|
@@ -1,7 +1,2 @@ | ||
- unless message[:error] | ||
= h params[:rpd] | ||
Requests per day is | ||
= @rps | ||
Requests per second | ||
|
||
= partial :rps | ||
= partial :rps |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
= link_to 'about', 'http://github.com/jackdempsey/builtbythenet/tree/master' | ||
= link_to 'about', 'http://github.com/jackdempsey/builtbythenet/tree/master', :target => :blank | ||
| | ||
= link_to 'request a feature', 'http://builtbythenet.uservoice.com/' | ||
= link_to 'request a feature', 'http://builtbythenet.uservoice.com/', :target => :blank |
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 |
---|---|---|
@@ -1,24 +1,33 @@ | ||
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb') | ||
|
||
describe "/home/rps_calc" do | ||
it "should return 100 RPS for a input of 8.64 million" do | ||
request("/home/rps_calc", :params => {:rpd => 8_640_000}).should contain('100') | ||
|
||
it "should redirect to / if request is a GET" do | ||
request("/home/rps_calc").should redirect | ||
end | ||
|
||
it "should show an error message if RPD is < 86,400" do | ||
request("/home/rps_calc", :params => {:rpd => 86399}).should have_selector('div#error') | ||
it "should convert to RPS by default" do | ||
request("/home/rps_calc", :params => {:requests_per => 8_640_000}).should contain('reqs/day is 100 reqs/sec') | ||
end | ||
|
||
it "should handle numbers with commas in them" do | ||
request("/home/rps_calc", :params => {:rpd => '8,640,000'}).should contain('100') | ||
request("/home/rps_calc", :params => {:requests_per => '8,640,000'}).should contain('100') | ||
end | ||
|
||
it "should show the RPD and RPS" do | ||
request("/home/rps_calc", :params => {:rpd => '8,640,000'}).should contain('8,640,000') | ||
describe "converting into RPS" do | ||
it "should return 100 RPS for a input of 8.64 million" do | ||
request("/home/rps_calc", :params => {:requests_per => 8_640_000}).should contain('100') | ||
end | ||
|
||
it "should show an error message if requests_per is < 86,400" do | ||
request("/home/rps_calc", :params => {:requests_per => 86399}).should have_selector('div#error') | ||
end | ||
end | ||
|
||
it "should redirect to / if request is a GET" do | ||
request("/home/rps_calc").should redirect | ||
|
||
describe "converting into RPD" do | ||
it "should return 8.64 million reqs/day for a input of 100 reqs/sec" do | ||
request("/home/rps_calc", :params => {:requests_per => 100, :convert_to => 'rpd'}).should contain('100 reqs/sec is 8640000 reqs/day') | ||
end | ||
end | ||
|
||
end |