Skip to content

Commit

Permalink
Generating GuitarsController Using Rails Generate Controller
Browse files Browse the repository at this point in the history
Replacing the existing controller created with the mock data
  • Loading branch information
LiorKGOW committed Dec 20, 2022
1 parent b163eb3 commit f069609
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/guitars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the guitars controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
4 changes: 4 additions & 0 deletions app/controllers/guitars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def index
}
]
end

def guitar_gallery; end

def welcome_page; end
end

# rubocop:enable Metrics/MethodLength
4 changes: 4 additions & 0 deletions app/helpers/guitars_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# frozen_string_literal: true

module GuitarsHelper
end
1 change: 1 addition & 0 deletions app/views/guitars/guitar_gallery.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Guitars#guitarGallery</h1>
1 change: 1 addition & 0 deletions app/views/guitars/welcome_page.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Guitars#welcomePage</h1>
7 changes: 6 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# frozen_string_literal: true

Rails.application.routes.draw do
root 'home#index'
get 'guitars/guitar_gallery'
get 'guitars/welcome_page'

# route to get the mock data:
get '/guitars', to: 'guitars#index'

root 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
9 changes: 7 additions & 2 deletions test/controllers/guitars_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
require 'test_helper'

class GuitarsControllerTest < ActionDispatch::IntegrationTest
test 'get index' do
get guitars_index_url
test 'should get guitarGallery' do
get guitars_guitar_gallery_url
assert_response :success
end

test 'should get welcomePage' do
get guitars_welcome_page_url
assert_response :success
end
end

0 comments on commit f069609

Please sign in to comment.