diff --git a/.gitignore b/.gitignore index 7259ed9..bdcfdfb 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ /config/master.key # /config/database.yml coverage/* +.env diff --git a/app/controllers/api/v1/cities_controller.rb b/app/controllers/api/v1/cities_controller.rb new file mode 100644 index 0000000..f216af3 --- /dev/null +++ b/app/controllers/api/v1/cities_controller.rb @@ -0,0 +1,10 @@ +module Api + module V1 + class CitiesController < ApplicationController + skip_before_action :validate_token, only: [:index] + def index + render json: City.all.order(:name).as_json + end + end + end + end \ No newline at end of file diff --git a/config/database.yml b/config/database.yml index 3e523ae..da1bf38 100644 --- a/config/database.yml +++ b/config/database.yml @@ -45,7 +45,6 @@ development: # Schema search path. The server defaults to $user,public #schema_search_path: myapp,sharedapp,public - # Minimum log levels, in increasing order: # debug5, debug4, debug3, debug2, debug1, # log, notice, warning, error, fatal, and panic diff --git a/config/routes.rb b/config/routes.rb index e7eccac..1ff0dc9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ get "/city_sport_levels", to: "levels#all_levels" resources :levels post "/level_sports", to: "level_sports#create" + resources :cities, only: [:index] end end end diff --git a/db/schema.rb b/db/schema.rb index 1ffd04b..399e616 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -95,23 +95,14 @@ create_table "users", force: :cascade do |t| t.string "first_name" t.string "last_name" - t.string "contact_number" - t.boolean "is_admin" + t.integer "contact_number" + t.boolean "role" + t.string "email" + t.string "password" t.bigint "city_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.string "email", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" t.index ["city_id"], name: "index_users_on_city_id" - t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - t.index ["email"], name: "index_users_on_email", unique: true - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end add_foreign_key "user_city_sports", "level_city_sports", column: "level_city_sports_id" diff --git a/spec/requests/get_cities_spec.rb b/spec/requests/get_cities_spec.rb new file mode 100644 index 0000000..b2cf45f --- /dev/null +++ b/spec/requests/get_cities_spec.rb @@ -0,0 +1,11 @@ +require "rails_helper" + +describe "get all cities", type: :request do + before do + get "/api/v1/cities" + end + + it "returns http success" do + expect(response).to have_http_status(:success) + end +end \ No newline at end of file