mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix few errors
This commit is contained in:
parent
3996d4c9dc
commit
b0b0a11c30
6 changed files with 60 additions and 2 deletions
1
Gemfile
1
Gemfile
|
|
@ -27,6 +27,7 @@ gem 'activerecord-postgis-adapter'
|
||||||
gem 'puma'
|
gem 'puma'
|
||||||
gem 'pundit'
|
gem 'pundit'
|
||||||
gem 'rails', '~> 8.0'
|
gem 'rails', '~> 8.0'
|
||||||
|
gem 'rexml'
|
||||||
gem 'rgeo'
|
gem 'rgeo'
|
||||||
gem 'rgeo-activerecord'
|
gem 'rgeo-activerecord'
|
||||||
gem 'rswag-api'
|
gem 'rswag-api'
|
||||||
|
|
|
||||||
|
|
@ -506,6 +506,7 @@ DEPENDENCIES
|
||||||
pundit
|
pundit
|
||||||
rails (~> 8.0)
|
rails (~> 8.0)
|
||||||
redis
|
redis
|
||||||
|
rexml
|
||||||
rgeo
|
rgeo
|
||||||
rgeo-activerecord
|
rgeo-activerecord
|
||||||
rspec-rails
|
rspec-rails
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rexml/document'
|
||||||
|
|
||||||
class Gpx::TrackImporter
|
class Gpx::TrackImporter
|
||||||
include Imports::Broadcaster
|
include Imports::Broadcaster
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="hero-content text-center">
|
<div class="hero-content text-center">
|
||||||
<div class="max-w-md">
|
<div class="max-w-md">
|
||||||
<h1 class="text-5xl font-bold">Hello there!</h1>
|
<h1 class="text-5xl font-bold">Hello there!</h1>
|
||||||
<% if current_user.active_until.future? %>
|
<% if current_user.active_until&.future? %>
|
||||||
<p class="py-6">
|
<p class="py-6">
|
||||||
You are currently subscribed to Dawarich, hurray!
|
You are currently subscribed to Dawarich, hurray!
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ class RunInitialVisitSuggestion < ActiveRecord::Migration[7.1]
|
||||||
start_at = 30.years.ago
|
start_at = 30.years.ago
|
||||||
end_at = Time.current
|
end_at = Time.current
|
||||||
|
|
||||||
VisitSuggestingJob.perform_later(start_at:, end_at:)
|
User.find_each do |user|
|
||||||
|
VisitSuggestingJob.perform_later(user_id: user.id, start_at:, end_at:)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,24 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
require 'sidekiq/web'
|
||||||
|
|
||||||
RSpec.describe '/sidekiq', type: :request do
|
RSpec.describe '/sidekiq', type: :request do
|
||||||
|
before do
|
||||||
|
# Allow any ENV key to be accessed and return nil by default
|
||||||
|
allow(ENV).to receive(:[]).and_return(nil)
|
||||||
|
|
||||||
|
# Stub Sidekiq::Web with a simple Rack app for testing
|
||||||
|
allow(Sidekiq::Web).to receive(:call) do |_env|
|
||||||
|
[200, { 'Content-Type' => 'text/html' }, ['Sidekiq Web UI']]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when Dawarich is in self-hosted mode' do
|
context 'when Dawarich is in self-hosted mode' do
|
||||||
before do
|
before do
|
||||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(true)
|
allow(DawarichSettings).to receive(:self_hosted?).and_return(true)
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_USERNAME').and_return(nil)
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_PASSWORD').and_return(nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user is not authenticated' do
|
context 'when user is not authenticated' do
|
||||||
|
|
@ -48,6 +61,8 @@ RSpec.describe '/sidekiq', type: :request do
|
||||||
context 'when Dawarich is not in self-hosted mode' do
|
context 'when Dawarich is not in self-hosted mode' do
|
||||||
before do
|
before do
|
||||||
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_USERNAME').and_return(nil)
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_PASSWORD').and_return(nil)
|
||||||
Rails.application.reload_routes!
|
Rails.application.reload_routes!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -70,4 +85,41 @@ RSpec.describe '/sidekiq', type: :request do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when SIDEKIQ_USERNAME and SIDEKIQ_PASSWORD are set' do
|
||||||
|
before do
|
||||||
|
allow(DawarichSettings).to receive(:self_hosted?).and_return(false)
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_USERNAME').and_return('admin')
|
||||||
|
allow(ENV).to receive(:[]).with('SIDEKIQ_PASSWORD').and_return('password')
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is not authenticated' do
|
||||||
|
it 'redirects to sign in page' do
|
||||||
|
get sidekiq_url
|
||||||
|
|
||||||
|
expect(response).to redirect_to('/users/sign_in')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is not admin' do
|
||||||
|
before { sign_in create(:user) }
|
||||||
|
|
||||||
|
it 'redirects to root page' do
|
||||||
|
get sidekiq_url
|
||||||
|
|
||||||
|
expect(response).to redirect_to(root_url)
|
||||||
|
expect(flash[:error]).to eq('You are not authorized to perform this action.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is admin' do
|
||||||
|
before { sign_in create(:user, :admin) }
|
||||||
|
|
||||||
|
it 'renders a successful response' do
|
||||||
|
get sidekiq_url
|
||||||
|
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue