From 8b54e53743dd72eb47766b63ae2beef7c1e5cbda Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 16 Mar 2016 11:39:24 +0800 Subject: [PATCH] metacode icon tests --- spec/models/metacode_spec.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spec/models/metacode_spec.rb b/spec/models/metacode_spec.rb index 6e6435b0..fc31e3e1 100644 --- a/spec/models/metacode_spec.rb +++ b/spec/models/metacode_spec.rb @@ -3,4 +3,21 @@ require 'rails_helper' RSpec.describe Metacode, type: :model do it { is_expected.to have_many :topics } it { is_expected.to have_many :metacode_sets } + + context 'BOTH aws_icon and manual_icon' do + let(:icon) { File.open(Rails.root.join('app', 'assets', 'images', + 'user.png')) } + let(:metacode) { build(:metacode, aws_icon: icon, + manual_icon: 'https://metamaps.cc/assets/user.png') } + it 'raises a validation error' do + expect { metacode.save! }.to raise_error ActiveRecord::RecordInvalid + end + end + + context 'NEITHER aws_icon or manual_icon' do + let(:metacode2) { build(:metacode, aws_icon: nil, manual_icon: nil) } + it 'raises a validation error' do + expect { metacode2.save! }.to raise_error ActiveRecord::RecordInvalid + end + end end