map spec
This commit is contained in:
parent
2525a6fb65
commit
696bac17e6
4 changed files with 17 additions and 2 deletions
|
@ -17,7 +17,7 @@ class Map < ActiveRecord::Base
|
||||||
validates :arranged, presence: true
|
validates :arranged, presence: true
|
||||||
validates :arranged, inclusion: { in: [true, false] }
|
validates :arranged, inclusion: { in: [true, false] }
|
||||||
validates :permission, presence: true
|
validates :permission, presence: true
|
||||||
validates :permission, inclusion: { in: Perm::ISSIONS }
|
validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) }
|
||||||
|
|
||||||
# Validate the attached image is image/jpg, image/png, etc
|
# Validate the attached image is image/jpg, image/png, etc
|
||||||
validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/
|
validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/
|
||||||
|
|
7
spec/factories/maps.rb
Normal file
7
spec/factories/maps.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :map do
|
||||||
|
name { random_string(10) }
|
||||||
|
permission :commons
|
||||||
|
user
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,11 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Map, type: :model do
|
RSpec.describe Map, type: :model do
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
# TODO: what is it important to be sure about when working with a Map?
|
||||||
|
it { is_expected.to belong_to :user }
|
||||||
|
it { is_expected.to validate_presence_of :name }
|
||||||
|
it { is_expected.to validate_presence_of :arranged }
|
||||||
|
it { is_expected.to validate_presence_of :permission }
|
||||||
|
it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,4 +40,6 @@ RSpec.configure do |config|
|
||||||
|
|
||||||
config.include Devise::TestHelpers, type: :controller
|
config.include Devise::TestHelpers, type: :controller
|
||||||
config.include ControllerHelpers, type: :controller
|
config.include ControllerHelpers, type: :controller
|
||||||
|
config.include Shoulda::Matchers::ActiveModel, type: :model
|
||||||
|
config.include Shoulda::Matchers::ActiveRecord, type: :model
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue