mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 17:31:18 -04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f086209f5c |
@@ -121,6 +121,11 @@ class CropsController < ApplicationController
|
||||
if can?(:wrangle, @crop)
|
||||
@crop.approval_status = 'rejected' if params.fetch("reject", false)
|
||||
@crop.approval_status = 'approved' if params.fetch("approve", false)
|
||||
if params.fetch("restore", false)
|
||||
@crop.approval_status = 'pending'
|
||||
@crop.reason_for_rejection = nil
|
||||
@crop.rejection_notes = nil
|
||||
end
|
||||
end
|
||||
|
||||
@crop.creator = current_member if @crop.approval_status == "pending"
|
||||
|
||||
@@ -120,6 +120,8 @@
|
||||
.text-right
|
||||
- if @crop.approved?
|
||||
= f.submit 'Save'
|
||||
- elsif @crop.rejected?
|
||||
= f.submit 'Restore', class: 'btn btn-warning', name: 'restore'
|
||||
- else
|
||||
= f.submit 'Reject', class: 'btn btn-danger', name: 'reject'
|
||||
= f.submit 'Approve and save', class: 'btn btn-success', name: 'approve'
|
||||
|
||||
@@ -66,6 +66,15 @@ describe "crop wranglers", :js do
|
||||
visit crop_path(rejected_crop)
|
||||
expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
|
||||
end
|
||||
|
||||
it "can restore a rejected crop" do
|
||||
visit edit_crop_path(rejected_crop)
|
||||
click_button "Restore"
|
||||
expect(page).to have_content "crop was successfully updated"
|
||||
rejected_crop.reload
|
||||
expect(rejected_crop).to be_pending
|
||||
expect(rejected_crop.reason_for_rejection).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user