This file contains hidden or 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
require 'rails_helper' | |
RSpec.describe GymsController, type: :controller do | |
let(:gym) { Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "[email protected]" )} | |
let(:climber) { User.create!(email: '[email protected]', password: '123456', first_name: 'test', last_name: 'test', user_name: 'climber') } | |
let!(:gym_create) {{ gym_name: "The Castle Gym", about: "Classic multi story climbing gym in central london", address: "Finsbury Park - London", email: "[email protected]" } } | |
before do | |
sign_in(climber) | |
end |
This file contains hidden or 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
require 'rails_helper' | |
RSpec.describe GymsController, type: :controller do | |
let(:gym) { Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "[email protected]" )} | |
let(:climber) { User.create!(email: '[email protected]', password: '123456', first_name: 'test', last_name: 'test', user_name: 'climber') } | |
let(:gym_create) {{ gym_name: "The Castle Gym", about: "Classic multi story climbing gym in central london", address: "Finsbury Park - London", email: "[email protected]" } } | |
before do | |
sign_in(climber) | |
end |
This file contains hidden or 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
require 'rails_helper' | |
RSpec.describe TodosController, :type => :controller do | |
describe "GET #index" do | |
#describe "POST #create" do | |
#describe "GET #show" do | |
#describe "PATCH #update" do (or PUT #update) | |
#describe "DELETE #destroy" do | |
#describe "GET #new" do |
This file contains hidden or 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
require 'rails_helper' | |
require 'pry' | |
RSpec.describe UsersController, type: :controller do | |
before(:example) do | |
@climber = User.create!(email: '[email protected]', password: '123456', first_name: 'test', last_name: 'test', | |
user_name: 'climber') | |
@setter = User.create!(email: '[email protected]', password: '123456', first_name: 'test', last_name: 'test', |
This file contains hidden or 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 should contain all the record creation needed to seed the database with its default values. | |
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). | |
# | |
# Examples: | |
# | |
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) | |
# Character.create(name: 'Luke', movie: movies.first) | |
## Creating users |
This file contains hidden or 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
def index | |
if params[:gym_id] | |
@gym = Gym.find(params[:gym_id]) | |
@routes = Route.where("gym_id = #{@gym.id}") | |
elsif params[:user_id] | |
@user = User.find(params[:user_id]) | |
@routes = Route.where("user_id = #{@user.id}") | |
else | |
@routes = Route.all | |
end |
This file contains hidden or 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
class RoutesController < ApplicationController | |
def index | |
if params[:gym_id] | |
@gym = Gym.find(params[:gym_id]) | |
@routes = Route.where("gym_id = #{@gym.id}") | |
elsif params[:user_id] | |
@user = User.find(params[:user_id]) | |
@routes = Route.where("user_id = #{@user.id}") | |
else |
This file contains hidden or 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
<h1> Add a route to this gym </h1> | |
<br> | |
<%= form_for :route, url: { action: "create" }, method: 'post' do |f| %> | |
<div class="field"> | |
<%= f.label :route_identifier %><br> | |
<%= f.text_field :route_identifier %> | |
</div> | |
<div class="field"> | |
<%= f.label :grade %><br> |
This file contains hidden or 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
def new | |
@route = Route.new | |
@gym = Gym.find(params[:gym_id]) | |
end | |
def create | |
if current_user.route_setter | |
#binding.pry |
This file contains hidden or 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
<h1> Add a route to this gym <h1> | |
<br> | |
<%= form_for :route, url: { action: "create" }, method: 'post' do |f| %> | |
<div class="field"> | |
<%= f.label :route_identifier %><br> | |
<%= f.text_field :route_identifier %> | |
</div> | |
<div class="field"> | |
<%= f.label :grade %><br> | |
<%= f.text_field :grade %> |