Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-06-01 16:06:30 +0300
committerDouwe Maan <douwe@gitlab.com>2017-06-01 16:06:30 +0300
commit483d88a9cdc8dc8f699b962c206eaa007aa370ef (patch)
treefed5d381bce05e823eb45d7d499c592122f39581 /spec
parentc72abcefe79dd906cbbf0088b442a8979e9fc746 (diff)
parentcd74c1434e42f7e6aa12fe2e2b8d9b1e56aea78f (diff)
Merge branch 'document-not-using-serialize' into 'master'
Document not using ActiveRecord's serialize method See merge request !11821
Diffstat (limited to 'spec')
-rw-r--r--spec/rubocop/cop/activerecord_serialize_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/rubocop/cop/activerecord_serialize_spec.rb b/spec/rubocop/cop/activerecord_serialize_spec.rb
new file mode 100644
index 00000000000..a303b16d264
--- /dev/null
+++ b/spec/rubocop/cop/activerecord_serialize_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+require 'rubocop'
+require 'rubocop/rspec/support'
+require_relative '../../../rubocop/cop/activerecord_serialize'
+
+describe RuboCop::Cop::ActiverecordSerialize do
+ include CopHelper
+
+ subject(:cop) { described_class.new }
+
+ context 'inside the app/models directory' do
+ it 'registers an offense when serialize is used' do
+ allow(cop).to receive(:in_models?).and_return(true)
+
+ inspect_source(cop, 'serialize :foo')
+
+ aggregate_failures do
+ expect(cop.offenses.size).to eq(1)
+ expect(cop.offenses.map(&:line)).to eq([1])
+ end
+ end
+ end
+
+ context 'outside the app/models directory' do
+ it 'does nothing' do
+ allow(cop).to receive(:in_models?).and_return(false)
+
+ inspect_source(cop, 'serialize :foo')
+
+ expect(cop.offenses).to be_empty
+ end
+ end
+end