aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/operation_spec.rb
blob: 6c59f21128c0ae6f04afc585f6bbe93e29dbfbd3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'rails_helper'

RSpec.describe Operation, type: :model do
  let(:organisation) {
    build(:organisation)
    # Operation.create!(
    #   name: "MyString"
    # )
  }

  # before(:each) do
  #   assign(:operation, operation)
  # end
  subject { described_class.new(name: "Spuds", organisation: organisation) }

  describe "associations" do
    it { should belong_to(:organisation).class_name('Organisation') }
  end

  describe "existence" do
    it "exists!" do
      expect(subject).to be_valid
    end
  end

  describe "validations" do
    it "is invalid without a name" do
      subject.name = nil
      expect(subject).to be_invalid
    end

    it "is invalid with a name longer than 35 chars" do
      subject.name = "a" * 36
      expect(subject).to be_invalid
    end
  end
end