Create dummy rails app with combustion and first tests
parent
66fb7733b4
commit
6257d03e45
|
@ -1,5 +1,6 @@
|
|||
*.gem
|
||||
*.rbc
|
||||
*.sqlite
|
||||
.bundle
|
||||
.config
|
||||
.yardoc
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class Moderation < ActiveRecord::Base
|
||||
include TheModerator::ModerationModel
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
class Page < ActiveRecord::Base
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
test:
|
||||
adapter: sqlite3
|
||||
database: db/combustion_test.sqlite
|
|
@ -0,0 +1,3 @@
|
|||
Rails.application.routes.draw do
|
||||
#
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
ActiveRecord::Schema.define do
|
||||
create_table :pages, :force => true do |t|
|
||||
t.string :name
|
||||
t.text :content
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :moderations, :force => true do |t|
|
||||
t.integer :moderatable_id
|
||||
t.string :moderatable_type
|
||||
t.text :data
|
||||
t.timestamps
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
*.log
|
|
@ -0,0 +1,14 @@
|
|||
require 'bundler/setup'
|
||||
require 'combustion'
|
||||
|
||||
require 'the_moderator'
|
||||
|
||||
Combustion.initialize! :active_record, :active_model
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.treat_symbols_as_metadata_keys_with_true_values = true
|
||||
config.run_all_when_everything_filtered = true
|
||||
config.filter_run :focus
|
||||
|
||||
config.order = 'random'
|
||||
end
|
|
@ -0,0 +1,24 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe TheModerator::Model do
|
||||
subject { Page.new(name: 'Name', content: 'Content') }
|
||||
|
||||
describe '#moderate' do
|
||||
it 'moderates simple field' do
|
||||
subject.moderate(:name)
|
||||
|
||||
expect(subject.moderations).to have(1).moderation
|
||||
expect(subject.name).to eq(nil)
|
||||
expect(subject.content).to eq('Content')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#moderated?' do
|
||||
it 'detects moderated field' do
|
||||
subject.moderate(:name)
|
||||
|
||||
expect(subject.moderated?(:name)).to be_true
|
||||
expect(subject.moderated?(:content)).to be_false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -23,4 +23,9 @@ Gem::Specification.new do |spec|
|
|||
|
||||
spec.add_development_dependency "bundler", "~> 1.3"
|
||||
spec.add_development_dependency "rake"
|
||||
|
||||
spec.add_development_dependency "rspec", "~> 2.14.0"
|
||||
spec.add_development_dependency "combustion", "~> 0.5.0"
|
||||
spec.add_development_dependency "sqlite3"
|
||||
spec.add_development_dependency "pry"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue