From d12cec8487282e0937ad6c4f0bab89565abca394 Mon Sep 17 00:00:00 2001 From: Bilal Date: Tue, 14 Jul 2020 18:47:43 +0200 Subject: [PATCH] remove validation and add specs --- app/models/task_request.rb | 2 -- .../user_managing_task_requests_spec.rb | 31 +++++++++++++++++++ spec/models/task_request_spec.rb | 4 --- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/models/task_request.rb b/app/models/task_request.rb index 04345ac..458e86a 100644 --- a/app/models/task_request.rb +++ b/app/models/task_request.rb @@ -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 diff --git a/spec/features/user_managing_task_requests_spec.rb b/spec/features/user_managing_task_requests_spec.rb index c40cd88..6174088 100644 --- a/spec/features/user_managing_task_requests_spec.rb +++ b/spec/features/user_managing_task_requests_spec.rb @@ -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 diff --git a/spec/models/task_request_spec.rb b/spec/models/task_request_spec.rb index 2e67c29..cf5ea56 100644 --- a/spec/models/task_request_spec.rb +++ b/spec/models/task_request_spec.rb @@ -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