Skip to content

Code for example rails challenge #145

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions source/.byebug_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
continue
assert_select ".successful-charges>tbody>tr", count: 10
assert_select ".successful-charges>tbody>tr"
Customer.count
Transaction.count
a.count
a=[#<Nokogiri::XML::Element:0x2afe62f76c38 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f76968 "Johny Flow">]>, #<Nokogiri::XML::Element:0x2afe62f766e8 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f76490 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f76224 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f79eb0 "2020-09-19 11:29:58 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f79a78 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f797a8 "Johny Flow">]>, #<Nokogiri::XML::Element:0x2afe62f795dc name="td" children=[#<Nokogiri::XML::Text:0x2afe62f793fc "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f7917c name="td" children=[#<Nokogiri::XML::Text:0x2afe62f78bb4 "2020-09-19 11:29:58 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f7868c name="td" children=[#<Nokogiri::XML::Text:0x2afe62f780c4 "Johny Flow">]>, #<Nokogiri::XML::Element:0x2afe62f7f540 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f7ee38 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f49468 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f49008 "2020-09-19 11:29:58 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f48c84 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f486e4 "Johny Flow">]>, #<Nokogiri::XML::Element:0x2afe62f484b4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f48298 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f480a4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f53eb8 "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f53b98 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f53238 "Johny Flow">]>, #<Nokogiri::XML::Element:0x2afe62f5306c name="td" children=[#<Nokogiri::XML::Text:0x2afe62f52e3c "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f52be4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f528d8 "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f526e4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f522d4 "Raj Jamnis">]>, #<Nokogiri::XML::Element:0x2afe62f520a4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f65d5c "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f65b68 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f65870 "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f65438 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f64ed4 "Raj Jamnis">]>, #<Nokogiri::XML::Element:0x2afe62f649c0 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f645c4 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f64204 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f67d3c "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f678f0 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f6765c "Raj Jamnis">]>, #<Nokogiri::XML::Element:0x2afe62f67418 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f67184 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f66fb8 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f66dc4 "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f66ba8 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f668d8 "Andrew Chung">]>, #<Nokogiri::XML::Element:0x2afe62f664a0 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f66090 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f6fba4 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f6f794 "2020-09-19 11:29:59 UTC">]>, #<Nokogiri::XML::Element:0x2afe62f6f26c name="td" children=[#<Nokogiri::XML::Text:0x2afe62f8be30 "Mike Smith">]>, #<Nokogiri::XML::Element:0x2afe62f8b994 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f8b570 "$750.74">]>, #<Nokogiri::XML::Element:0x2afe62f8b138 name="td" children=[#<Nokogiri::XML::Text:0x2afe62f8a60c "2020-09-19 11:29:59 UTC">]>]
assert_select ".successful-charges>tbody>tr>td"
continue
Transaction.count
Customer.count
assert_select ".successful-charges>tbody>tr>td"
assert_select ".failed-charges>tbody>tr>td", count: 5
assert_select ".disputed-charges>tbody>tr>td", count: 2
assert_select ".disputed-charges>tbody>tr>td"
assert_select ".failed-charges>tbody>tr>td"
assert_select "failed-charges>tbody>tr>td"
assert_select ".successful-charges>tbody>tr>td"
continue
assert_select ".failed-charges>tbody>tr>td"
assert_select ".failed-charges>tbody>tr"
assert_select ".failed-charges>tbody"
assert_select ".failed-charges"
assert_select ".failed-charges>tr"
assert_select ".failed-charges>tr>td"
assert_select ".failed-charges"
assert_select "tr>td"
17 changes: 17 additions & 0 deletions source/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
1 change: 1 addition & 0 deletions source/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.6
52 changes: 52 additions & 0 deletions source/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.11.3'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.3.13'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'factory_bot_rails'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

group :test do
gem 'database_cleaner'
end
193 changes: 193 additions & 0 deletions source/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.11.3)
actionpack (= 4.2.11.3)
actionview (= 4.2.11.3)
activejob (= 4.2.11.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.11.3)
actionview (= 4.2.11.3)
activesupport (= 4.2.11.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.11.3)
activesupport (= 4.2.11.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.11.3)
activesupport (= 4.2.11.3)
globalid (>= 0.3.0)
activemodel (4.2.11.3)
activesupport (= 4.2.11.3)
builder (~> 3.1)
activerecord (4.2.11.3)
activemodel (= 4.2.11.3)
activesupport (= 4.2.11.3)
arel (~> 6.0)
activesupport (4.2.11.3)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.4)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
builder (3.2.4)
byebug (11.1.3)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.7)
crass (1.0.6)
database_cleaner (1.8.5)
debug_inspector (0.0.3)
diff-lcs (1.4.4)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (5.2.0)
activesupport (>= 4.2.0)
factory_bot_rails (5.2.0)
factory_bot (~> 5.2.0)
railties (>= 4.2.0)
ffi (1.13.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.6)
loofah (2.7.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
rack (1.6.13)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.11.3)
actionmailer (= 4.2.11.3)
actionpack (= 4.2.11.3)
actionview (= 4.2.11.3)
activejob (= 4.2.11.3)
activemodel (= 4.2.11.3)
activerecord (= 4.2.11.3)
activesupport (= 4.2.11.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.11.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (4.2.11.3)
actionpack (= 4.2.11.3)
activesupport (= 4.2.11.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rdoc (4.3.0)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-rails (4.0.1)
actionpack (>= 4.2)
activesupport (>= 4.2)
railties (>= 4.2)
rspec-core (~> 3.9)
rspec-expectations (~> 3.9)
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (2.1.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (1.2.7)
thread_safe (~> 0.1)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
database_cleaner
factory_bot_rails
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.11.3)
rspec-rails
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
sqlite3 (~> 1.3.13)
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)

BUNDLED WITH
1.17.3
16 changes: 16 additions & 0 deletions source/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Development Setup

Install and switch to ruby version `2.6.6`

Run following commands on terminal
* `cd source && bundle install`
* `bundle exec rake db:create db:migrate db:seed`
* `bundle exec rails s`

App can be browsed on http://localhost:3000
* Charges -> http://localhost:3000/charges
* Customers -> http://localhost:3000/customers
* Transactions -> http://localhost:3000/transactions

The tests specified in rails challenge can be run with
* `bundle exec rspec spec/views/charges/index.html.erb_spec.rb`
6 changes: 6 additions & 0 deletions source/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks
Empty file added source/app/assets/images/.keep
Empty file.
16 changes: 16 additions & 0 deletions source/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
3 changes: 3 additions & 0 deletions source/app/assets/javascripts/customers.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions source/app/assets/javascripts/transactions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
15 changes: 15 additions & 0 deletions source/app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
3 changes: 3 additions & 0 deletions source/app/assets/stylesheets/customers.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the customers controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
Loading