diff --git a/.env.test b/.env.test index b5e9d76e..3a1129e5 100644 --- a/.env.test +++ b/.env.test @@ -1,4 +1,4 @@ -DATABASE_HOST=dawarich_db +DATABASE_HOST=localhost DATABASE_USERNAME=postgres DATABASE_PASSWORD=password DATABASE_NAME=dawarich_test diff --git a/app/models/import.rb b/app/models/import.rb index 02f1db7e..c6cf4d95 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -1,5 +1,5 @@ class Import < ApplicationRecord - belongs_to :user, dependent: :destroy + belongs_to :user has_many :points, dependent: :destroy enum source: { google: 0, owntracks: 1 } diff --git a/app/services/own_tracks/params.rb b/app/services/own_tracks/params.rb index f22b599d..b37abe77 100644 --- a/app/services/own_tracks/params.rb +++ b/app/services/own_tracks/params.rb @@ -4,7 +4,7 @@ class OwnTracks::Params attr_reader :params def initialize(params) - @params = params.deep_symbolize_keys + @params = params end def call diff --git a/spec/models/import_spec.rb b/spec/models/import_spec.rb index 66e8e1d9..a7f5b482 100644 --- a/spec/models/import_spec.rb +++ b/spec/models/import_spec.rb @@ -1,5 +1,8 @@ require 'rails_helper' RSpec.describe Import, type: :model do - pending "add some examples to (or delete) #{__FILE__}" + describe 'associations' do + it { is_expected.to have_many(:points).dependent(:destroy) } + it { is_expected.to belong_to(:user) } + end end diff --git a/spec/models/point_spec.rb b/spec/models/point_spec.rb index eeda85b6..86284d69 100644 --- a/spec/models/point_spec.rb +++ b/spec/models/point_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe Point, type: :model do describe 'associations' do - it { is_expected.to belong_to(:tracker).optional } + it { is_expected.to belong_to(:import).optional } end describe 'validations' do diff --git a/spec/requests/points_spec.rb b/spec/requests/points_spec.rb index bfa208f9..7d9f2705 100644 --- a/spec/requests/points_spec.rb +++ b/spec/requests/points_spec.rb @@ -2,10 +2,24 @@ require 'rails_helper' RSpec.describe "Points", type: :request do describe "GET /index" do - it "returns http success" do - get "/points/index" - expect(response).to have_http_status(:success) + context 'when user signed in' do + before do + sign_in create(:user) + end + + it "returns http success" do + get points_path + + expect(response).to have_http_status(:success) + end + end + + context 'when user not signed in' do + it "returns http success" do + get points_path + + expect(response).to have_http_status(302) + end end end - end