-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #539 from richardlences/feature/dont_allow_to_dele…
…te_message_while_being_sent don't allow to delete message while being sent
- Loading branch information
Showing
3 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'test_helper' | ||
|
||
class MessageDraftsControllerTest < ActionController::TestCase | ||
setup do | ||
session[:login_expires_at] = Time.now + 1.day | ||
Current.user = users(:basic) | ||
session[:user_id] = Current.user.id | ||
end | ||
test "should destroy draft if it was not yet submitted" do | ||
message_draft = messages(:ssd_main_draft) | ||
delete :destroy, params: { id: message_draft.id } | ||
assert_raises(ActiveRecord::RecordNotFound) do | ||
MessageDraft.find(message_draft.id) | ||
end | ||
end | ||
|
||
test "should not destroy draft that is being submitted" do | ||
message_draft = messages(:ssd_main_draft) | ||
message_draft.metadata[:status] = "being_submitted" | ||
message_draft.save! | ||
delete :destroy, params: { id: message_draft.id } | ||
assert_equal "Správu nie je možné zmazať po zaradení na odoslanie", flash[:alert] | ||
assert MessageDraft.exists?(message_draft.id) | ||
end | ||
end |