Skip to content

Commit

Permalink
Made home controller with index page, added pry gem and made inital f…
Browse files Browse the repository at this point in the history
…orm for link submission
  • Loading branch information
anujmohatkar committed Dec 29, 2021
1 parent c8b4a1a commit 568146e
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails', '~> 5.0.0'
gem 'rails-controller-testing'
gem 'pry-rails'
end

group :development do
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GEM
msgpack (~> 1.0)
builder (3.2.4)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.9)
crass (1.0.6)
diff-lcs (1.5.0)
Expand All @@ -90,6 +91,11 @@ GEM
nio4r (2.5.8)
nokogiri (1.12.5-x64-mingw32)
racc (~> 1.4)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
puma (5.5.2)
nio4r (~> 2.0)
racc (1.6.0)
Expand Down Expand Up @@ -159,6 +165,8 @@ GEM
sprockets-rails
tilt
semantic_range (3.0.0)
serviceworker-rails (0.6.0)
railties (>= 3.1)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down Expand Up @@ -198,12 +206,14 @@ DEPENDENCIES
bootsnap (>= 1.4.4)
byebug
jbuilder (~> 2.7)
pry-rails
puma (~> 5.0)
rack-mini-profiler (~> 2.0)
rails (~> 6.1.4, >= 6.1.4.1)
rails-controller-testing
rspec-rails (~> 5.0.0)
sass-rails (>= 6)
serviceworker-rails
sqlite3 (~> 1.4)
turbolinks (~> 5)
tzinfo-data
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
5 changes: 5 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class HomeController < ApplicationController
def index
@link = Link.new
end
end
1 change: 1 addition & 0 deletions app/controllers/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class LinksController < ApplicationController
def create
shortener = Shortener.new(link_params[:original_url])
@link = shortener.generate_short_link
binding.pry
end

private
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomeHelper
end
7 changes: 7 additions & 0 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1>Home#index</h1>
<p>Find me in app/views/home/index.html.erb</p>

<%= form_for @link, remote: true do |form| %>
<%= form.text_field :original_url %>
<%= form.submit %>
<% end %>
2 changes: 2 additions & 0 deletions app/views/links/create.js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var lookupCode = "<%= @link.lookup_code %>";
console.log(lookupCode);
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
root to: 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
post "/links" => 'links#create'
end
15 changes: 15 additions & 0 deletions spec/helpers/home_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the HomeHelper. For example:
#
# describe HomeHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe HomeHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
11 changes: 11 additions & 0 deletions spec/requests/home_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'rails_helper'

RSpec.describe "Homes", type: :request do
#describe "GET /index" do
# it "returns http success" do
# get "/home/index"
# expect(response).to have_http_status(:success)
# end
# end

end
5 changes: 5 additions & 0 deletions spec/views/home/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe "home/index.html.erb", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 568146e

Please sign in to comment.