Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNigel23 committed Oct 17, 2024
1 parent d737404 commit c20f8f8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/article_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def update

flash[:notice] = t('.subjects_auto_linking')
redirect_to collection_article_edit_path(@collection.owner, @collection, @article)
else
# Default to redirect
redirect_to collection_article_edit_path(@collection.owner, @collection, @article)
end
end

Expand Down
40 changes: 40 additions & 0 deletions spec/requests/article_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
let(:action_path) { collection_article_update_path(owner, collection, article) }
let(:subject) { patch action_path, params: params }

it 'redirects' do
login_as owner
subject

expect(response).to have_http_status(:redirect)
expect(response).to redirect_to(collection_article_edit_path(owner, collection, article))
end

context 'when failed save' do
let(:params) do
{
Expand Down Expand Up @@ -132,4 +140,36 @@
end
end
end

describe '#assign_category' do
let!(:article) { create(:article, collection: collection) }
let(:status) { 'true' }
let(:params) do
{
status: status,
category_id: category.id
}
end

let(:action_path) { article_article_category_path(article_id: article.id) }
let(:subject) { post action_path, params: params }

it 'renders status' do
login_as owner
subject

expect(response).to have_http_status(:ok)
end

context 'status false' do
let(:status) { 'false' }

it 'renders status' do
login_as owner
subject

expect(response).to have_http_status(:ok)
end
end
end
end

0 comments on commit c20f8f8

Please sign in to comment.