mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 01:01:39 -05:00
Implemented imports editing
This commit is contained in:
parent
8cc8b9d157
commit
02490c62a4
3 changed files with 71 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ This is optional feature and is not required for the app to work.
|
|||
## Added
|
||||
|
||||
- You can now provide SMTP settings in ENV vars to send emails.
|
||||
- You can now edit imports. #1044 #623
|
||||
|
||||
|
||||
# 0.25.4 - 2025-04-02
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class ImportsController < ApplicationController
|
|||
|
||||
before_action :authenticate_user!
|
||||
before_action :authenticate_active_user!, only: %i[new create]
|
||||
before_action :set_import, only: %i[show destroy]
|
||||
before_action :set_import, only: %i[show edit update destroy]
|
||||
|
||||
def index
|
||||
@imports =
|
||||
|
|
@ -18,10 +18,18 @@ class ImportsController < ApplicationController
|
|||
|
||||
def show; end
|
||||
|
||||
def edit; end
|
||||
|
||||
def new
|
||||
@import = Import.new
|
||||
end
|
||||
|
||||
def update
|
||||
@import.update(import_params)
|
||||
|
||||
redirect_to imports_url, notice: 'Import was successfully updated.', status: :see_other
|
||||
end
|
||||
|
||||
def create
|
||||
files = import_params[:files].reject(&:blank?)
|
||||
|
||||
|
|
|
|||
|
|
@ -77,4 +77,65 @@ RSpec.describe 'Imports', type: :request do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /imports/new' do
|
||||
context 'when user is logged in' do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'returns http success' do
|
||||
get new_import_path
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /imports/:id' do
|
||||
context 'when user is logged in' do
|
||||
let(:user) { create(:user) }
|
||||
let!(:import) { create(:import, user:) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'deletes the import' do
|
||||
expect do
|
||||
delete import_path(import)
|
||||
end.to change(user.imports, :count).by(-1)
|
||||
|
||||
expect(response).to redirect_to(imports_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /imports/:id/edit' do
|
||||
context 'when user is logged in' do
|
||||
let(:user) { create(:user) }
|
||||
let(:import) { create(:import, user:) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'returns http success' do
|
||||
get edit_import_path(import)
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH /imports/:id' do
|
||||
context 'when user is logged in' do
|
||||
let(:user) { create(:user) }
|
||||
let(:import) { create(:import, user:) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
it 'updates the import' do
|
||||
patch import_path(import), params: { import: { name: 'New Name' } }
|
||||
|
||||
expect(response).to redirect_to(imports_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue