remove validation and add specs

This commit is contained in:
Bilal
2020-07-14 18:47:43 +02:00
parent bde18ab0f1
commit d12cec8487
3 changed files with 31 additions and 6 deletions

View File

@@ -5,6 +5,4 @@ class TaskRequest < ApplicationRecord
enum status: [:pending, :completed, :cancelled]
scope :order_by_recent, -> { order(created_at: :desc) }
validates :time_allowed, numericality: { only_integer: true, greater_than_or_equal_to: 2 }
end

View File

@@ -91,6 +91,21 @@ feature "User managing task requests" do
expect(page).to have_content add_new_project_label
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
def no_task_requests_label
@@ -120,4 +135,20 @@ feature "User managing task requests" do
def schedule_demo
t 'task_requests.splash.actions.book_demo'
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

View File

@@ -13,8 +13,4 @@ RSpec.describe TaskRequest, type: :model do
subject { described_class }
it { is_expected.to respond_to(:order_by_recent) }
end
describe "#validations" do
it { should validate_numericality_of(:time_allowed).only_integer.is_greater_than_or_equal_to(2) }
end
end