remove validation and add specs
This commit is contained in:
@@ -5,6 +5,4 @@ class TaskRequest < ApplicationRecord
|
|||||||
enum status: [:pending, :completed, :cancelled]
|
enum status: [:pending, :completed, :cancelled]
|
||||||
|
|
||||||
scope :order_by_recent, -> { order(created_at: :desc) }
|
scope :order_by_recent, -> { order(created_at: :desc) }
|
||||||
|
|
||||||
validates :time_allowed, numericality: { only_integer: true, greater_than_or_equal_to: 2 }
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -91,6 +91,21 @@ feature "User managing task requests" do
|
|||||||
expect(page).to have_content add_new_project_label
|
expect(page).to have_content add_new_project_label
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "user can click Chat Now and start chat event with a blank form" do
|
||||||
|
visit project_task_requests_path(project)
|
||||||
|
|
||||||
|
click_on create_task_request
|
||||||
|
|
||||||
|
expect(page).to have_content chat_now_button
|
||||||
|
expect(page).to have_content form_notice
|
||||||
|
|
||||||
|
expect do
|
||||||
|
click_on chat_now_button
|
||||||
|
end.to change(TaskRequest, :count).by(1)
|
||||||
|
|
||||||
|
expect(page).to have_content task_request_created_notice
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def no_task_requests_label
|
def no_task_requests_label
|
||||||
@@ -120,4 +135,20 @@ feature "User managing task requests" do
|
|||||||
def schedule_demo
|
def schedule_demo
|
||||||
t 'task_requests.splash.actions.book_demo'
|
t 'task_requests.splash.actions.book_demo'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_task_request
|
||||||
|
t 'task_requests.index.actions.new'
|
||||||
|
end
|
||||||
|
|
||||||
|
def chat_now_button
|
||||||
|
t 'task_requests.form.actions.chat_now'
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_notice
|
||||||
|
t 'task_requests.form.info_message'
|
||||||
|
end
|
||||||
|
|
||||||
|
def task_request_created_notice
|
||||||
|
t 'task_requests.create.success_message'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,8 +13,4 @@ RSpec.describe TaskRequest, type: :model do
|
|||||||
subject { described_class }
|
subject { described_class }
|
||||||
it { is_expected.to respond_to(:order_by_recent) }
|
it { is_expected.to respond_to(:order_by_recent) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#validations" do
|
|
||||||
it { should validate_numericality_of(:time_allowed).only_integer.is_greater_than_or_equal_to(2) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user