增加后台管理,并将mongoid切回2.x版本, 因为rspec过不了
This commit is contained in:
parent
3ccd40c93b
commit
51248c60ff
25
Gemfile
25
Gemfile
|
@ -22,29 +22,20 @@ group :assets do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'cucumber-rails'
|
||||
gem 'factory_girl'
|
||||
gem 'mongoid-rspec', :require => false
|
||||
#gem 'capybara'
|
||||
#gem 'cucumber-rails'
|
||||
#gem 'factory_girl'
|
||||
#gem 'mongoid-rspec', :require => false
|
||||
end
|
||||
|
||||
group :test, :development do
|
||||
gem 'rspec-rails'
|
||||
gem "rspec-rails", ">= 2.8.1"
|
||||
end
|
||||
|
||||
gem 'jquery-rails'
|
||||
|
||||
# To use ActiveModel has_secure_password
|
||||
# gem 'bcrypt-ruby', '~> 3.0.0'
|
||||
|
||||
# To use Jbuilder templates for JSON
|
||||
# gem 'jbuilder'
|
||||
|
||||
# Use unicorn as the app server
|
||||
# gem 'unicorn'
|
||||
|
||||
# Deploy with Capistrano
|
||||
# gem 'capistrano'
|
||||
|
||||
# To use debugger
|
||||
# gem 'debugger'
|
||||
gem "bluecloth"
|
||||
gem "simple_form"
|
||||
gem 'database_cleaner'
|
||||
|
|
62
Gemfile.lock
62
Gemfile.lock
|
@ -28,21 +28,12 @@ GEM
|
|||
activesupport (3.2.6)
|
||||
i18n (~> 0.6)
|
||||
multi_json (~> 1.0)
|
||||
addressable (2.2.8)
|
||||
arel (3.0.2)
|
||||
bluecloth (2.2.0)
|
||||
bson (1.6.4)
|
||||
bson_ext (1.6.4)
|
||||
bson (~> 1.6.4)
|
||||
builder (3.0.0)
|
||||
capybara (1.1.2)
|
||||
mime-types (>= 1.16)
|
||||
nokogiri (>= 1.3.3)
|
||||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
selenium-webdriver (~> 2.0)
|
||||
xpath (~> 0.1.4)
|
||||
childprocess (0.3.2)
|
||||
ffi (~> 1.0.6)
|
||||
coffee-rails (3.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (~> 3.2.0)
|
||||
|
@ -50,24 +41,11 @@ GEM
|
|||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.3.3)
|
||||
cucumber (1.2.1)
|
||||
builder (>= 2.1.2)
|
||||
diff-lcs (>= 1.1.3)
|
||||
gherkin (~> 2.11.0)
|
||||
json (>= 1.4.6)
|
||||
cucumber-rails (1.3.0)
|
||||
capybara (>= 1.1.2)
|
||||
cucumber (>= 1.1.8)
|
||||
nokogiri (>= 1.5.0)
|
||||
database_cleaner (0.8.0)
|
||||
diff-lcs (1.1.3)
|
||||
erubis (2.7.0)
|
||||
execjs (1.4.0)
|
||||
multi_json (~> 1.0)
|
||||
factory_girl (3.5.0)
|
||||
activesupport (>= 3.0.0)
|
||||
ffi (1.0.11)
|
||||
gherkin (2.11.0)
|
||||
json (>= 1.4.6)
|
||||
hike (1.2.1)
|
||||
i18n (0.6.0)
|
||||
journey (1.0.4)
|
||||
|
@ -75,26 +53,18 @@ GEM
|
|||
railties (>= 3.2.0, < 5.0)
|
||||
thor (~> 0.14)
|
||||
json (1.7.3)
|
||||
libwebsocket (0.1.3)
|
||||
addressable
|
||||
mail (2.4.4)
|
||||
i18n (>= 0.4.0)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.19)
|
||||
mongoid (3.0.0.rc)
|
||||
mongo (1.6.2)
|
||||
bson (~> 1.6.2)
|
||||
mongoid (2.4.11)
|
||||
activemodel (~> 3.1)
|
||||
moped (~> 1.0.0.rc)
|
||||
origin (~> 1.0.0.rc)
|
||||
mongo (<= 1.6.2)
|
||||
tzinfo (~> 0.3.22)
|
||||
mongoid-rspec (1.4.6)
|
||||
mongoid (>= 3.0.0.rc)
|
||||
rake
|
||||
rspec (>= 2.9)
|
||||
moped (1.0.0.rc)
|
||||
multi_json (1.3.6)
|
||||
nokogiri (1.5.4)
|
||||
origin (1.0.1)
|
||||
polyglot (0.3.3)
|
||||
rack (1.4.1)
|
||||
rack-cache (1.2)
|
||||
|
@ -134,17 +104,14 @@ GEM
|
|||
activesupport (>= 3.0)
|
||||
railties (>= 3.0)
|
||||
rspec (~> 2.10.0)
|
||||
rubyzip (0.9.9)
|
||||
sass (3.1.19)
|
||||
sass-rails (3.2.5)
|
||||
railties (~> 3.2.0)
|
||||
sass (>= 3.1.10)
|
||||
tilt (~> 1.3)
|
||||
selenium-webdriver (2.24.0)
|
||||
childprocess (>= 0.2.5)
|
||||
libwebsocket (~> 0.1.3)
|
||||
multi_json (~> 1.0)
|
||||
rubyzip
|
||||
simple_form (2.0.2)
|
||||
actionpack (~> 3.0)
|
||||
activemodel (~> 3.0)
|
||||
sprockets (2.1.3)
|
||||
hike (~> 1.2)
|
||||
rack (~> 1.0)
|
||||
|
@ -158,22 +125,19 @@ GEM
|
|||
uglifier (1.2.5)
|
||||
execjs (>= 0.3.0)
|
||||
multi_json (~> 1.3)
|
||||
xpath (0.1.4)
|
||||
nokogiri (~> 1.3)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bluecloth
|
||||
bson_ext
|
||||
capybara
|
||||
coffee-rails (~> 3.2.1)
|
||||
cucumber-rails
|
||||
factory_girl
|
||||
database_cleaner
|
||||
jquery-rails
|
||||
mongoid
|
||||
mongoid-rspec
|
||||
rails (= 3.2.6)
|
||||
rspec-rails
|
||||
rspec-rails (>= 2.8.1)
|
||||
sass-rails (~> 3.2.3)
|
||||
simple_form
|
||||
uglifier (>= 1.0.3)
|
||||
|
|
|
@ -4,5 +4,6 @@ class BlogsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@post = Post.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
# encoding : utf-8
|
||||
class Post
|
||||
TECH = "技术"
|
||||
LIFE = "生活"
|
||||
CREATOR = "创业"
|
||||
include Mongoid::Document
|
||||
field :title, :type => String
|
||||
field :content, :type => String
|
||||
field :type, :type=> String
|
||||
|
||||
validates :title, :presence=>true, :uniqueness=> true
|
||||
validates :content, :presence=>true, :length => { :minimum=> 30 }
|
||||
validates :type, :presence=>true, :inclusion => { :in => [ TECH, LIFE, CREATOR ] }
|
||||
end
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
<h1>Blogs#show</h1>
|
||||
<p>Find me in app/views/blogs/show.html.erb</p>
|
||||
<div class="blog">
|
||||
<h2><%= @post.title %></h2>
|
||||
<div class="content"><%= @post.content %></div>
|
||||
</div>
|
||||
|
|
|
@ -1,60 +1,20 @@
|
|||
development:
|
||||
# Configure available database sessions. (required)
|
||||
sessions:
|
||||
# Defines the default session. (required)
|
||||
default:
|
||||
# Defines the name of the default database that Mongoid can connect to.
|
||||
# (required).
|
||||
host: localhost
|
||||
database: w_blog_development
|
||||
# Provides the hosts the default session can connect to. Must be an array
|
||||
# of host:port pairs. (required)
|
||||
hosts:
|
||||
- localhost:27017
|
||||
options:
|
||||
# Change whether the session persists in safe mode by default.
|
||||
# (default: false)
|
||||
# safe: false
|
||||
|
||||
# Change the default consistency model to :eventual or :strong.
|
||||
# :eventual will send reads to secondaries, :strong sends everything
|
||||
# to master. (default: :eventual)
|
||||
consistency: :strong
|
||||
# Configure Mongoid specific options. (optional)
|
||||
options:
|
||||
# Configuration for whether or not to allow access to fields that do
|
||||
# not have a field definition on the model. (default: true)
|
||||
# allow_dynamic_fields: true
|
||||
test:
|
||||
host: localhost
|
||||
database: w_blog_test
|
||||
|
||||
# Enable the identity map, needed for eager loading. (default: false)
|
||||
# identity_map_enabled: false
|
||||
|
||||
# Includes the root model name in json serialization. (default: false)
|
||||
# include_root_in_json: false
|
||||
|
||||
# Include the _type field in serializaion. (default: false)
|
||||
# include_type_for_serialization: false
|
||||
|
||||
# Preload all models in development, needed when models use
|
||||
# inheritance. (default: false)
|
||||
# preload_models: false
|
||||
|
||||
# Protect id and type from mass assignment. (default: true)
|
||||
# protect_sensitive_fields: true
|
||||
|
||||
# Raise an error when performing a #find and the document is not found.
|
||||
# (default: true)
|
||||
# raise_not_found_error: true
|
||||
|
||||
# Raise an error when defining a scope with the same name as an
|
||||
# existing method. (default: false)
|
||||
# scope_overwrite_exception: false
|
||||
|
||||
# Skip the database version check, used when connecting to a db without
|
||||
# admin access. (default: false)
|
||||
# skip_version_check: false
|
||||
|
||||
# User Active Support's time zone in conversions. (default: true)
|
||||
# use_activesupport_time_zone: true
|
||||
|
||||
# Ensure all times are UTC in the app side. (default: false)
|
||||
# use_utc: false
|
||||
# set these environment variables on your prod server
|
||||
production:
|
||||
host: <%= ENV['MONGOID_HOST'] %>
|
||||
port: <%= ENV['MONGOID_PORT'] %>
|
||||
username: <%= ENV['MONGOID_USERNAME'] %>
|
||||
password: <%= ENV['MONGOID_PASSWORD'] %>
|
||||
database: <%= ENV['MONGOID_DATABASE'] %>
|
||||
# slaves:
|
||||
# - host: slave1.local
|
||||
# port: 27018
|
||||
# - host: slave2.local
|
||||
# port: 27019
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
WBlog::Application.routes.draw do
|
||||
root :to => 'blogs#index'
|
||||
resources :blogs, :only=>[:index, :show]
|
||||
namespace :admin do
|
||||
resources :posts
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Post do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
it "validates should be ok" do
|
||||
a = Post.create!(title: 'one', content: '1'*31, type: Post::TECH )
|
||||
a.save.should == true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,15 +13,21 @@ RSpec.configure do |config|
|
|||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
# clear test data
|
||||
config.after :suite do
|
||||
Mongoid.master.collections.select do |collection|
|
||||
collection.name !~ /system/
|
||||
end.each(&:drop)
|
||||
|
||||
config.before :each do
|
||||
DatabaseCleaner.strategy = :truncation
|
||||
DatabaseCleaner.start
|
||||
end
|
||||
|
||||
config.after do
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
config.mock_with :rspec
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
#config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
|
Loading…
Reference in New Issue