2015-10-12 03:37:44 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2015-12-16 14:19:58 +00:00
|
|
|
RSpec.describe Metacode, type: :model do
|
2016-01-26 09:29:18 +00:00
|
|
|
it { is_expected.to have_many :topics }
|
|
|
|
it { is_expected.to have_many :metacode_sets }
|
2016-03-16 03:39:24 +00:00
|
|
|
|
|
|
|
context 'BOTH aws_icon and manual_icon' do
|
2016-07-26 00:14:23 +00:00
|
|
|
let(:icon) do
|
|
|
|
File.open(Rails.root.join('app', 'assets', 'images',
|
|
|
|
'user.png'))
|
|
|
|
end
|
|
|
|
let(:metacode) do
|
|
|
|
build(:metacode, aws_icon: icon,
|
|
|
|
manual_icon: 'https://metamaps.cc/assets/user.png')
|
|
|
|
end
|
2016-03-16 03:39:24 +00:00
|
|
|
it 'raises a validation error' do
|
|
|
|
expect { metacode.save! }.to raise_error ActiveRecord::RecordInvalid
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'NEITHER aws_icon or manual_icon' do
|
2016-03-16 03:42:51 +00:00
|
|
|
let(:metacode) { build(:metacode, aws_icon: nil, manual_icon: nil) }
|
2016-03-16 03:39:24 +00:00
|
|
|
it 'raises a validation error' do
|
2016-03-16 03:42:51 +00:00
|
|
|
expect { metacode.save! }.to raise_error ActiveRecord::RecordInvalid
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'non-https manual icon' do
|
|
|
|
let(:metacode) { build(:metacode, manual_icon: 'http://metamaps.cc/assets/user.png') }
|
|
|
|
it 'raises a validation error' do
|
|
|
|
expect { metacode.save! }.to raise_error ActiveRecord::RecordInvalid
|
2016-03-16 03:39:24 +00:00
|
|
|
end
|
|
|
|
end
|
2015-10-12 03:37:44 +00:00
|
|
|
end
|