Merge branch 'rails_3_1' of github.com:locomotivecms/engine into rails_3_1

This commit is contained in:
did 2011-12-07 02:09:35 +01:00
commit eacdb2873e
9 changed files with 39 additions and 87 deletions

View File

@ -9,7 +9,7 @@ GIT
GIT
remote: git://github.com/locomotivecms/custom_fields.git
revision: af88a1602442c1507152426a5dcac662695c55ef
revision: af21782109d5b4f073949f8f123fb56c6c7227ef
specs:
custom_fields (1.1.0.rc1)
activesupport (~> 3.1.1)

View File

@ -5,7 +5,7 @@ Given /^I am not authenticated$/ do
end
Given /^I am an authenticated "([^"]*)"$/ do |role|
@member = Site.first.memberships.where(:role => role.downcase).first || FactoryGirl.create(role.downcase.to_sym, :site => Site.first)
@member = Locomotive::Site.first.memberships.where(:role => role.downcase).first || FactoryGirl.create(role.downcase.to_sym, :site => Locomotive::Site.first)
step %{I go to login}
step %{I fill in "Email" with "#{@member.account.email}"}

View File

@ -1,5 +1,5 @@
Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
site = Site.first
site = Locomotive::Site.first
content_type = FactoryGirl.build(:content_type, :site => site, :name => name)
fields.hashes.each do |field|
if (target_name = field.delete('target')).present?
@ -14,7 +14,7 @@ Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
end
Given /^I set up a reverse has_many relationship between "([^"]*)" and "([^"]*)"$/ do |name_1, name_2|
site = Site.first
site = Locomotive::Site.first
content_type_1 = site.content_types.where(:name => name_1).first
content_type_2 = site.content_types.where(:name => name_2).first
@ -30,7 +30,7 @@ Given /^I set up a reverse has_many relationship between "([^"]*)" and "([^"]*)"
end
Given %r{^I have "([^"]*)" as "([^"]*)" values of the "([^"]*)" model$} do |values, field, name|
content_type = ContentType.where(:name => name).first
content_type = Locomotive::ContentType.where(:name => name).first
field = content_type.contents_custom_fields.detect { |f| f.label == field }
field.should_not be_nil
@ -45,7 +45,7 @@ Given %r{^I have "([^"]*)" as "([^"]*)" values of the "([^"]*)" model$} do |valu
end
Given %r{^I have entries for "([^"]*)" with$} do |name, entries|
content_type = ContentType.where(:name => name).first
content_type = Locomotive::ContentType.where(:name => name).first
entries.hashes.each do |entry|
content_type.contents.create(entry)
end
@ -53,7 +53,7 @@ Given %r{^I have entries for "([^"]*)" with$} do |name, entries|
end
When %r{^I change the presentation of the "([^"]*)" model by grouping items by "([^"]*)"$} do |name, field|
content_type = ContentType.where(:name => name).first
content_type = Locomotive::ContentType.where(:name => name).first
field = content_type.contents_custom_fields.detect { |f| f.label == field }
content_type.group_by_field_name = field._name
content_type.save.should be_true

View File

@ -1,4 +1,4 @@
# Creates a Site record
# Creates a Locomotive::Site record
#
# examples:
# - I have the site: "some site" set up
@ -18,12 +18,12 @@ Given /^I have a site set up$/ do
end
Given /^I have a designer and an author$/ do
FactoryGirl.create(:designer, :site => Site.first)
FactoryGirl.create(:author, :site => Site.first)
FactoryGirl.create(:designer, :site => Locomotive::Site.first)
FactoryGirl.create(:author, :site => Locomotive::Site.first)
end
Then /^I should be a administrator of the "([^"]*)" site$/ do |name|
site = Site.where(:name => name).first
site = Locomotive::Site.where(:name => name).first
m = site.memberships.detect { |m| m.account_id == @admin._id && m.admin? }
m.should_not be_nil
end

View File

@ -11,4 +11,4 @@ each do |within, selector|
Then step
end
end
end
end

View File

@ -4,15 +4,16 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
ENV['RAILS_ENV'] ||= 'test'
ENV["RAILS_ROOT"] ||= File.join(File.dirname(__FILE__), '../', '../', 'spec', 'dummy')
require 'cucumber/rails'
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/rspec'
require 'cucumber/rails/world'
require 'factory_girl'
require 'capybara'
require 'capybara/rails'
require 'capybara/cucumber'
@ -67,4 +68,6 @@ ActionController::Base.allow_rescue = false
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/carrierwave')
require File.expand_path(File.dirname(__FILE__) + '/../../spec/support/locomotive')
World(Locomotive::Engine.routes.url_helpers) # Load engine routes
Locomotive.configure_for_test(true)

View File

@ -1,4 +1,6 @@
module NavigationHelpers
include Locomotive::Engine.routes.url_helpers # Load engine routes
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
@ -11,35 +13,35 @@ module NavigationHelpers
when /the home\s?page$/
'/'
when /login/
new_admin_session_path
new_locomotive_account_session_path
when /logout/
destroy_admin_session_path
destroy_locomotive_account_session_url
when /pages( list)?/
admin_pages_path
locomotive_pages_path
when /new page/
new_admin_page_path
new_locomotive_page_path
when /"(.*)" edition page/
page = Site.first.pages.where(:slug => $1).first
edit_admin_page_path(page)
edit_locomotive_page_path(page)
when /theme assets/
admin_theme_assets_path
locomotive_theme_assets_path
when /site settings/
edit_admin_current_site_path
edit_locomotive_current_site_path
when /account settings/
edit_admin_my_account_path
edit_locomotive_my_account_path
when /import page/
new_admin_import_path
new_locomotive_import_path
when /export page/
new_admin_export_path
new_locomotive_export_path
when /the "(.*)" model list page/
content_type = Site.first.content_types.where(:name => $1).first
admin_contents_path(content_type.slug)
content_type = Locomotive::Site.first.content_types.where(:name => $1).first
locomotive_contents_path(content_type.slug)
when /the "(.*)" model creation page/
content_type = Site.first.content_types.where(:name => $1).first
new_admin_content_path(content_type.slug)
content_type = Locomotive::Site.first.content_types.where(:name => $1).first
new_locomotive_content_path(content_type.slug)
when /the "(.*)" model edition page/
content_type = Site.first.content_types.where(:name => $1).first
edit_admin_content_type_path(content_type)
content_type = Locomotive::Site.first.content_types.where(:name => $1).first
edit_locomotive_content_type_path(content_type)
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
@ -61,58 +63,3 @@ module NavigationHelpers
end
World(NavigationHelpers)
# module NavigationHelpers
# # Maps a name to a path. Used by the
# #
# # When /^I go to (.+)$/ do |page_name|
# #
# # step definition in web_steps.rb
# #
# def path_to(page_name)
# case page_name
#
# when /the home\s?page/
# '/'
# when /login/
# new_admin_session_path
# when /logout/
# destroy_admin_session_path
# when /pages( list)?/
# admin_pages_path
# when /new page/
# new_admin_page_path
# when /"(.*)" edition page/
# page = Site.first.pages.where(:slug => $1).first
# edit_admin_page_path(page)
# when /theme assets/
# admin_theme_assets_path
# when /site settings/
# edit_admin_current_site_path
# when /import page/
# new_admin_import_path
# when /the "(.*)" model edition page/
# content_type = Site.first.content_types.where(:name => $1).first
# edit_admin_content_type_path(content_type)
#
# # Add more mappings here.
# # Here is an example that pulls values out of the Regexp:
# #
# # when /^(.*)'s profile page$/i
# # user_profile_path(User.find_by_login($1))
#
# else
# begin
# page_name =~ /the (.*) page/
# path_components = $1.split(/\s+/)
# self.send(path_components.push('path').join('_').to_sym)
# rescue Object => e
# raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
# "Now, go and add a mapping in #{__FILE__}"
# end
# end
# end
# end
#
# World(NavigationHelpers)

View File

@ -29,7 +29,7 @@ describe Locomotive::ApiContentsController do
describe 'API enabled' do
before(:each) do
ContentType.any_instance.stubs(:api_enabled?).returns(true)
Locomotive::ContentType.any_instance.stubs(:api_enabled?).returns(true)
end
it 'saves a content' do

View File

@ -2,6 +2,8 @@ require 'spec_helper'
class MyController < ActionController::Base
include Locomotive::Routing::SiteDispatcher
include Locomotive::Engine.routes.url_helpers # Required for loading engine routes
end
describe Locomotive::Routing::SiteDispatcher do