diff --git a/Gemfile b/Gemfile
index 59968d8..c129f0a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -5,9 +5,9 @@ source "http://rubygems.org"
# development dependencies will be added by default to the :development group.
gemspec
-gem "rails", "4.2.0"
+gem "rails", " ~> 4.2.3"
group :assets do
- gem 'sass-rails', ' ~> 5.0.0'
+ gem 'sass-rails' #, ' ~> 5.0.0'
gem 'bourbon'
gem 'coffee-script'
#gem 'therubyracer', :platforms => :ruby
@@ -26,7 +26,7 @@ gem 'orm_adapter', github: 'bterkuile/orm_adapter'
gem 'devise'
gem 'devise_simply_stored', github: 'bterkuile/devise_simply_stored'
gem 'slim-rails'
-gem 'paperclip'
+gem 'paperclip', ['>= 3.4', '!= 4.3.0']
gem 'email_validator'
gem 'actionpack-page_caching'
# Declare any dependencies that are still in development here instead of in
@@ -35,14 +35,16 @@ gem 'actionpack-page_caching'
# your gem to rubygems.org.
# To use debugger
-group :test do
- gem 'steak'
- gem 'rspec-its'
+group :development, :test do
+ gem 'rspec-rails'
gem 'pry-rails'
+end
+group :test do
gem 'factory_girl_rails'
+ gem 'capybara'
+ gem 'rspec-its'
end
group :development do
- gem 'pry-rails'
gem 'thin'
#gem 'ruby-debug19', :require => 'ruby-debug'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index cd650e2..f530942 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -22,7 +22,7 @@ GIT
GIT
remote: git://github.com/bterkuile/simply_stored.git
- revision: 652caf8c2cfe4f828477f8b76d0cd201851cd53d
+ revision: 8e8288b20ab64d62f1da7516731cd936f81b1f19
specs:
simply_stored (1.0.0)
activesupport
@@ -48,44 +48,44 @@ GEM
remote: http://rubygems.org/
specs:
ace-rails-ap (3.0.3)
- actionmailer (4.2.0)
- actionpack (= 4.2.0)
- actionview (= 4.2.0)
- activejob (= 4.2.0)
+ actionmailer (4.2.3)
+ actionpack (= 4.2.3)
+ actionview (= 4.2.3)
+ activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
- actionpack (4.2.0)
- actionview (= 4.2.0)
- activesupport (= 4.2.0)
- rack (~> 1.6.0)
+ actionpack (4.2.3)
+ actionview (= 4.2.3)
+ activesupport (= 4.2.3)
+ rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-page_caching (1.0.2)
actionpack (>= 4.0.0, < 5)
- actionview (4.2.0)
- activesupport (= 4.2.0)
+ actionview (4.2.3)
+ activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
- rails-html-sanitizer (~> 1.0, >= 1.0.1)
- activejob (4.2.0)
- activesupport (= 4.2.0)
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
+ activejob (4.2.3)
+ activesupport (= 4.2.3)
globalid (>= 0.3.0)
- activemodel (4.2.0)
- activesupport (= 4.2.0)
+ activemodel (4.2.3)
+ activesupport (= 4.2.3)
builder (~> 3.1)
- activerecord (4.2.0)
- activemodel (= 4.2.0)
- activesupport (= 4.2.0)
+ activerecord (4.2.3)
+ activemodel (= 4.2.3)
+ activesupport (= 4.2.3)
arel (~> 6.0)
- activesupport (4.2.0)
+ activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
- arel (6.0.0)
+ arel (6.0.2)
bcrypt (3.1.10)
bourbon (4.2.3)
sass (~> 3.4)
@@ -106,11 +106,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
- couchrest (1.2.0)
- mime-types (~> 1.15)
- multi_json (~> 1.0)
- rest-client (~> 1.6.1)
- daemons (1.2.2)
+ couchrest (1.2.1)
+ mime-types (>= 1.15)
+ multi_json (~> 1.7, ~> 1.0)
+ rest-client (~> 1.8.0)
+ daemons (1.2.3)
devise (3.5.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@@ -119,6 +119,8 @@ GEM
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
+ domain_name (0.5.24)
+ unf (>= 0.0.5, < 1.0.0)
email_validator (1.6.0)
activemodel
erubis (2.7.0)
@@ -136,8 +138,10 @@ GEM
sass (>= 3.3.0, < 3.5)
globalid (0.3.5)
activesupport (>= 4.1.0)
+ http-cookie (1.0.2)
+ domain_name (~> 0.5)
i18n (0.7.0)
- jquery-rails (4.0.3)
+ jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
@@ -147,18 +151,19 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
- mime-types (1.25.1)
+ mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
- multi_json (1.11.0)
+ multi_json (1.11.2)
+ netrc (0.10.3)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
- paperclip (4.2.2)
- activemodel (>= 3.0.0)
- activesupport (>= 3.0.0)
- cocaine (~> 0.5.3)
+ paperclip (4.2.4)
+ activemodel (>= 3.2.0)
+ activesupport (>= 3.2.0)
+ cocaine (~> 0.5.5)
mime-types
- pickadate-rails (3.5.5.0)
+ pickadate-rails (3.5.6.0)
railties (>= 3.1.0)
pry (0.10.1)
coderay (~> 1.1.0)
@@ -166,19 +171,19 @@ GEM
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
- rack (1.6.1)
+ rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
- rails (4.2.0)
- actionmailer (= 4.2.0)
- actionpack (= 4.2.0)
- actionview (= 4.2.0)
- activejob (= 4.2.0)
- activemodel (= 4.2.0)
- activerecord (= 4.2.0)
- activesupport (= 4.2.0)
+ rails (4.2.3)
+ actionmailer (= 4.2.3)
+ actionpack (= 4.2.3)
+ actionview (= 4.2.3)
+ activejob (= 4.2.3)
+ activemodel (= 4.2.3)
+ activerecord (= 4.2.3)
+ activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
- railties (= 4.2.0)
+ railties (= 4.2.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
@@ -188,39 +193,39 @@ GEM
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
- railties (4.2.0)
- actionpack (= 4.2.0)
- activesupport (= 4.2.0)
+ railties (4.2.3)
+ actionpack (= 4.2.3)
+ activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
- rdoc (4.2.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
- rest-client (1.6.8)
- mime-types (~> 1.16)
- rdoc (>= 2.4.2)
- rspec-core (3.2.3)
- rspec-support (~> 3.2.0)
- rspec-expectations (3.2.1)
+ rest-client (1.8.0)
+ http-cookie (>= 1.0.2, < 2.0)
+ mime-types (>= 1.16, < 3.0)
+ netrc (~> 0.7)
+ rspec-core (3.3.1)
+ rspec-support (~> 3.3.0)
+ rspec-expectations (3.3.0)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.2.0)
+ rspec-support (~> 3.3.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
- rspec-mocks (3.2.1)
+ rspec-mocks (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
- rspec-support (~> 3.2.0)
- rspec-rails (3.2.3)
+ rspec-support (~> 3.3.0)
+ rspec-rails (3.3.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
- rspec-core (~> 3.2.0)
- rspec-expectations (~> 3.2.0)
- rspec-mocks (~> 3.2.0)
- rspec-support (~> 3.2.0)
- rspec-support (3.2.2)
- sass (3.4.14)
+ rspec-core (~> 3.3.0)
+ rspec-expectations (~> 3.3.0)
+ rspec-mocks (~> 3.3.0)
+ rspec-support (~> 3.3.0)
+ rspec-support (3.3.0)
+ sass (3.4.16)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
@@ -239,13 +244,10 @@ GEM
slop (3.6.0)
sprockets (3.2.0)
rack (~> 1.0)
- sprockets-rails (2.3.1)
+ sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
- steak (2.0.0)
- capybara (>= 1.0.0)
- rspec-rails (>= 2.5.0)
temple (0.7.6)
thin (1.6.3)
daemons (~> 1.0, >= 1.0.9)
@@ -258,6 +260,9 @@ GEM
railties (>= 3.1.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.7.1)
warden (1.2.3)
rack (>= 1.0)
xpath (2.0.0)
@@ -270,6 +275,7 @@ DEPENDENCIES
ace-rails-ap
actionpack-page_caching
bourbon
+ capybara
cmtool!
coffee-script
couch_potato!
@@ -281,14 +287,14 @@ DEPENDENCIES
foundation-rails
jquery-rails
orm_adapter!
- paperclip
+ paperclip (>= 3.4, != 4.3.0)
pickadate-rails
pry-rails
- rails (= 4.2.0)
+ rails (~> 4.2.3)
rspec-its
- sass-rails (~> 5.0.0)
+ rspec-rails
+ sass-rails
simply_stored!
slim-rails
- steak
thin
tinymce-rails
diff --git a/README.md b/README.md
index 79d4a9e..d94721f 100644
--- a/README.md
+++ b/README.md
@@ -71,16 +71,18 @@ end
### Routing
-Add the following routes:
+Add the following routes with changes according to your application:
```ruby
+ALLOWED_LOCALES = /nl|de|fr|en|es/
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
mount Cmtool::Engine => '/cmtool'
+get '/:locale' => 'pages#home', constraints: {locale: ALLOWED_LOCALES}, as: :go_to_locale
get '/sitemap(.:format)' => 'pages#sitemap'
-scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do
+scope '(/:locale)', constraints: {locale: ALLOWED_LOCALES}, defaults: { locale: :nl } do
+ root to: 'pages#home'
get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page
end
get "/*url" => "pages#not_found"
-root :to => 'pages#home'
```
### User model
diff --git a/app/models/page.rb b/app/models/page.rb
index 7955dc6..8d3d4cd 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -1,3 +1,4 @@
class Page
include Cmtool::Includes::Page
+ view :by_locale, key: :locale
end
diff --git a/lib/cmtool/includes/pages_controller.rb b/lib/cmtool/includes/pages_controller.rb
index 532c4c9..2cd46cd 100644
--- a/lib/cmtool/includes/pages_controller.rb
+++ b/lib/cmtool/includes/pages_controller.rb
@@ -33,8 +33,10 @@ module Cmtool
def sitemap
respond_to do |format|
format.xml do
- page_uris = ::Page.for_sitemap.map{|p| page_path(p.name, locale: p.locale)}
- pages_xml = page_uris.map{|uri| "#{uri}"}.join("\n")
+ pages_xml = ::Page.for_sitemap.map do |page|
+ uri = page_path(page.name, locale: page.locale)
+ "#{uri}#{page.updated_at.strftime('%Y-%m-%d')}"
+ end.join("\n")
result = <<-XML
diff --git a/spec/acceptance/acceptance_helper.rb b/spec/acceptance/acceptance_helper.rb
deleted file mode 100644
index 71946ad..0000000
--- a/spec/acceptance/acceptance_helper.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'spec_helper'
-
-# Put your acceptance spec helpers inside spec/acceptance/support
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
\ No newline at end of file
diff --git a/spec/acceptance/support/paths.rb b/spec/acceptance/support/paths.rb
deleted file mode 100644
index e3b8307..0000000
--- a/spec/acceptance/support/paths.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module NavigationHelpers
- # Put helper methods related to the paths in your application here.
-
- def homepage
- "/"
- end
-end
-
-RSpec.configuration.include NavigationHelpers, :type => :acceptance
\ No newline at end of file
diff --git a/spec/dummy/config/environments/production.rb b/spec/dummy/config/environments/production.rb
index 56e3066..7e44916 100644
--- a/spec/dummy/config/environments/production.rb
+++ b/spec/dummy/config/environments/production.rb
@@ -9,7 +9,7 @@ Dummy::Application.configure do
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
- config.serve_static_assets = false
+ config.serve_static_files = false
# Compress JavaScripts and CSS
config.assets.compress = true
diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb
index 6feb3d2..42bcc5f 100644
--- a/spec/dummy/config/environments/test.rb
+++ b/spec/dummy/config/environments/test.rb
@@ -8,7 +8,7 @@ Dummy::Application.configure do
config.cache_classes = true
# Configure static asset server for tests with Cache-Control for performance
- config.serve_static_assets = true
+ config.serve_static_files = true
config.static_cache_control = "public, max-age=3600"
# Log error messages when you accidentally call methods on nil
diff --git a/spec/dummy/config/routes.rb b/spec/dummy/config/routes.rb
index 0398511..36b391b 100644
--- a/spec/dummy/config/routes.rb
+++ b/spec/dummy/config/routes.rb
@@ -2,7 +2,7 @@ Rails.application.routes.draw do
devise_for :users, :controllers => {:sessions => 'cmtool/sessions', :passwords => 'cmtool/passwords'}
mount Cmtool::Engine => "/cmtool"
- get '/sitemap(.:format)' => 'test_pages#sitemap'
+ get '/sitemap(.:format)' => 'pages#sitemap'
get "/:name" => "pages#show"
scope '(/:locale)', constraints: {locale: /nl|be|de|fr|en/}, defaults: { locale: :nl } do
get "/:name" => "pages#show", constraints: {name: /.*/}, as: :page
diff --git a/spec/acceptance/cmtool/pages_spec.rb b/spec/features/cmtool/pages_spec.rb
similarity index 89%
rename from spec/acceptance/cmtool/pages_spec.rb
rename to spec/features/cmtool/pages_spec.rb
index 15c0d82..2624cc9 100644
--- a/spec/acceptance/cmtool/pages_spec.rb
+++ b/spec/features/cmtool/pages_spec.rb
@@ -1,11 +1,6 @@
-require 'acceptance/acceptance_helper'
-
-feature 'Pages index', %q{
- In order have pages
- As a user
- I want to see pages
-} do
+require 'spec_helper'
+feature 'Pages index' do
scenario 'visit root' do
visit '/cmtool'
page.current_path.should == '/users/sign_in'
diff --git a/spec/features/cmtool/sitemap_spec.rb b/spec/features/cmtool/sitemap_spec.rb
new file mode 100644
index 0000000..305ba5e
--- /dev/null
+++ b/spec/features/cmtool/sitemap_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+
+feature 'sitemap.xml' do
+ scenario 'proper sitemap' do
+ p1 = Page.create name: 'nl-1', title: 'NL 1', locale: 'nl'
+ p1 = Page.create name: 'en-1', title: 'EN 1', locale: 'en'
+ visit "/sitemap.xml"
+ page.body.should include "#{Date.today.strftime('%Y-%m-%d')}"
+ page.body.should include "/en/en-1"
+ page.body.should include "/nl-1"
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 50e6db8..b019866 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -3,7 +3,6 @@ ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
-require 'rspec/autorun'
require 'factory_girl'
require 'capybara/rspec'
@@ -23,10 +22,13 @@ RSpec.configure do |config|
#config.include CompanyFactory
config.include Cmtool::Engine.routes.url_helpers
config.include Devise::TestHelpers, type: :controller
+ config.include FeatureHelpers, type: :feature
#config.use_transactional_fixtures = true
config.infer_base_class_for_anonymous_controllers = true
config.render_views = true
+ config.expect_with(:rspec) { |c| c.syntax = [:expect, :should] }
+
config.before :each do
CouchPotato.couchrest_database.recreate!
@user = User.first || create(:user)
diff --git a/spec/acceptance/support/helpers.rb b/spec/support/feature_helpers.rb
similarity index 83%
rename from spec/acceptance/support/helpers.rb
rename to spec/support/feature_helpers.rb
index 2f56cf5..1e38b9b 100644
--- a/spec/acceptance/support/helpers.rb
+++ b/spec/support/feature_helpers.rb
@@ -1,4 +1,4 @@
-module HelperMethods
+module FeatureHelpers
# Put helper methods you need to be available in all acceptance specs here.
def create_user(email, password='secret')
@user = User.find_by_email(email) || FactoryGirl.create(:user, email: email, password: password)
@@ -14,6 +14,8 @@ module HelperMethods
def submit_form
find("[type=submit]").click
end
-end
-RSpec.configuration.include HelperMethods, :type => :acceptance
+ def homepage
+ "/"
+ end
+end