alchemy_cms 2.2.2 → 2.2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +1 -1
- data/alchemy_cms.gemspec +0 -1
- data/app/helpers/alchemy/admin/base_helper.rb +3 -3
- data/app/models/alchemy/content.rb +8 -1
- data/app/models/alchemy/element.rb +15 -16
- data/app/models/alchemy/page.rb +1 -0
- data/lib/alchemy/essence.rb +7 -4
- data/lib/alchemy/version.rb +1 -1
- data/spec/controllers/admin/elements_controller_spec.rb +28 -0
- data/spec/controllers/admin/trash_controller_spec.rb +45 -12
- data/spec/dummy/config/locales/fo.yml +5 -0
- data/spec/integration/admin/pages_controller_spec.rb +1 -8
- data/spec/integration/admin/resources_integration_spec.rb +2 -2
- data/spec/integration/pages_controller_spec.rb +189 -191
- data/spec/integration/security_spec.rb +1 -1
- data/spec/models/element_spec.rb +204 -182
- data/spec/models/essence_boolean_spec.rb +1 -1
- data/spec/models/essence_select_spec.rb +1 -1
- data/spec/models/language_spec.rb +1 -1
- data/spec/models/page_spec.rb +1 -1
- data/spec/spec_helper.rb +14 -13
- data/spec/support/alchemy/specs_helpers.rb +27 -8
- data/spec/support/alchemy/test_tweaks.rb +35 -0
- metadata +7 -19
@@ -4,7 +4,7 @@ module Alchemy
|
|
4
4
|
describe EssenceBoolean do
|
5
5
|
|
6
6
|
it "should act as essence" do
|
7
|
-
expect { EssenceBoolean.new.acts_as_essence? }.
|
7
|
+
expect { EssenceBoolean.new.acts_as_essence? }.to_not raise_error(NoMethodError)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have correct partial path" do
|
@@ -4,7 +4,7 @@ module Alchemy
|
|
4
4
|
describe EssenceSelect do
|
5
5
|
|
6
6
|
it "should act as essence" do
|
7
|
-
expect { EssenceSelect.new.acts_as_essence? }.
|
7
|
+
expect { EssenceSelect.new.acts_as_essence? }.to_not raise_error(NoMethodError)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should have correct partial path" do
|
@@ -58,7 +58,7 @@ describe Alchemy::Language do
|
|
58
58
|
if !@default_language
|
59
59
|
@default_language = FactoryGirl.create(:language, :name => "default", :code => "aa", :frontpage_name => "intro", :default => true)
|
60
60
|
end
|
61
|
-
expect { @default_language.destroy }.
|
61
|
+
expect { @default_language.destroy }.to raise_error
|
62
62
|
end
|
63
63
|
|
64
64
|
describe "before save" do
|
data/spec/models/page_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -9,9 +9,6 @@ def configure
|
|
9
9
|
|
10
10
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
11
11
|
|
12
|
-
require 'database_cleaner'
|
13
|
-
DatabaseCleaner.strategy = :truncation
|
14
|
-
|
15
12
|
require 'authlogic/test_case'
|
16
13
|
include Authlogic::TestCase
|
17
14
|
|
@@ -25,6 +22,8 @@ def configure
|
|
25
22
|
ActionMailer::Base.default_url_options[:host] = "test.com"
|
26
23
|
|
27
24
|
Rails.backtrace_cleaner.remove_silencers!
|
25
|
+
# Disable rails loggin for faster IO. Remove this if you want to have a test.log
|
26
|
+
Rails.logger.level = 4
|
28
27
|
|
29
28
|
# Configure capybara for integration testing
|
30
29
|
require "capybara/rails"
|
@@ -32,6 +31,9 @@ def configure
|
|
32
31
|
Capybara.default_driver = :rack_test
|
33
32
|
Capybara.default_selector = :css
|
34
33
|
Capybara.javascript_driver = :poltergeist
|
34
|
+
Capybara.register_driver(:rack_test_translated_header) do |app|
|
35
|
+
Capybara::RackTest::Driver.new(app, :headers => { 'HTTP_ACCEPT_LANGUAGE' => 'de' })
|
36
|
+
end
|
35
37
|
|
36
38
|
# Load support files
|
37
39
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
@@ -42,22 +44,21 @@ def configure
|
|
42
44
|
config.include Alchemy::Engine.routes.url_helpers
|
43
45
|
config.mock_with :rspec
|
44
46
|
config.use_transactional_fixtures = true
|
47
|
+
# Make sure the database is clean and ready for test
|
48
|
+
config.before(:suite) do
|
49
|
+
truncate_all_tables
|
50
|
+
Alchemy::Seeder.seed!
|
51
|
+
end
|
52
|
+
# Ensuring that the locale is always resetted to :en before running any tests
|
53
|
+
config.before(:each) do
|
54
|
+
::I18n.locale = :en
|
55
|
+
end
|
45
56
|
end
|
46
57
|
|
47
58
|
end
|
48
59
|
|
49
|
-
def seed
|
50
|
-
# This code will be run each time you run your specs.
|
51
|
-
DatabaseCleaner.clean
|
52
|
-
# Seed the database
|
53
|
-
Alchemy::Seeder.seed!
|
54
|
-
::I18n.locale = :en
|
55
|
-
end
|
56
|
-
|
57
60
|
if defined?(Spork)
|
58
61
|
Spork.prefork { configure }
|
59
|
-
Spork.each_run { seed }
|
60
62
|
else
|
61
63
|
configure
|
62
|
-
seed
|
63
64
|
end
|
@@ -2,22 +2,29 @@ require 'declarative_authorization/maintenance'
|
|
2
2
|
|
3
3
|
module Alchemy
|
4
4
|
module Specs
|
5
|
+
|
5
6
|
# Helpers for integration specs
|
7
|
+
#
|
6
8
|
# This file is auto included in rspec integration/request tests.
|
9
|
+
#
|
7
10
|
module Helpers
|
8
11
|
include Authorization::TestHelper
|
9
12
|
|
10
|
-
#
|
13
|
+
# Shortcut method for:
|
11
14
|
#
|
12
|
-
#
|
15
|
+
# * create_admin_user
|
16
|
+
# * login_into_alchemy
|
13
17
|
#
|
14
|
-
|
18
|
+
def authorize_as_admin
|
19
|
+
create_admin_user
|
20
|
+
login_into_alchemy
|
21
|
+
end
|
22
|
+
|
23
|
+
# Capybara actions to login into Alchemy Backend
|
15
24
|
#
|
16
|
-
#
|
25
|
+
# You should have a admin user before loggin in.
|
17
26
|
#
|
18
|
-
#
|
19
|
-
# create_admin_user
|
20
|
-
# end
|
27
|
+
# See: create_admin_user method
|
21
28
|
#
|
22
29
|
def login_into_alchemy
|
23
30
|
visit '/alchemy/admin/login'
|
@@ -27,18 +34,30 @@ module Alchemy
|
|
27
34
|
end
|
28
35
|
|
29
36
|
# Load additional authorization_rules for specs.
|
37
|
+
#
|
30
38
|
# For some strange reason, this isn't done automatically while running the specs
|
39
|
+
#
|
31
40
|
def load_authorization_rules
|
32
41
|
instance = Alchemy::AuthEngine.get_instance
|
33
42
|
instance.load(File.join(File.dirname(__FILE__), '../../dummy', 'config/authorization_rules.rb'))
|
34
43
|
end
|
35
44
|
|
36
45
|
# Creates an admin user in a way it works
|
46
|
+
#
|
47
|
+
# You should create it once in a before block
|
48
|
+
#
|
49
|
+
# === Example:
|
50
|
+
#
|
51
|
+
# before do
|
52
|
+
# create_admin_user
|
53
|
+
# end
|
54
|
+
#
|
37
55
|
def create_admin_user
|
38
|
-
@user
|
56
|
+
@user ||= FactoryGirl.build(:admin_user).save_without_session_maintenance
|
39
57
|
end
|
40
58
|
|
41
59
|
end
|
60
|
+
|
42
61
|
end
|
43
62
|
end
|
44
63
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Fixes Capybara database connection issues
|
2
|
+
# Found http://blog.plataformatec.com.br/2011/12/three-tips-to-improve-the-performance-of-your-test-suite/
|
3
|
+
|
4
|
+
class ActiveRecord::Base
|
5
|
+
mattr_accessor :shared_connection
|
6
|
+
@@shared_connection = nil
|
7
|
+
|
8
|
+
def self.connection
|
9
|
+
@@shared_connection || retrieve_connection
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Forces all threads to share the same connection. This works on
|
14
|
+
# Capybara because it starts the web server in a thread.
|
15
|
+
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
16
|
+
|
17
|
+
# fast truncation of all tables that need truncations (select is 10x faster then truncate)
|
18
|
+
# http://grosser.it/2012/07/03/rubyactiverecord-fastest-way-to-truncate-test-database/
|
19
|
+
def truncate_all_tables
|
20
|
+
config = ActiveRecord::Base.configurations[::Rails.env]
|
21
|
+
connection = ActiveRecord::Base.connection
|
22
|
+
connection.disable_referential_integrity do
|
23
|
+
connection.tables.each do |table_name|
|
24
|
+
next if connection.select_value("SELECT count(*) FROM #{table_name}") == 0
|
25
|
+
case config["adapter"]
|
26
|
+
when "mysql2", "postgresql"
|
27
|
+
connection.execute("TRUNCATE #{table_name}")
|
28
|
+
when "sqlite3"
|
29
|
+
connection.execute("DELETE FROM #{table_name}")
|
30
|
+
connection.execute("DELETE FROM sqlite_sequence where name='#{table_name}'")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
connection.execute("VACUUM") if config["adapter"] == "sqlite3"
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-
|
15
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -270,22 +270,6 @@ dependencies:
|
|
270
270
|
- - ! '>='
|
271
271
|
- !ruby/object:Gem::Version
|
272
272
|
version: '0'
|
273
|
-
- !ruby/object:Gem::Dependency
|
274
|
-
name: database_cleaner
|
275
|
-
requirement: !ruby/object:Gem::Requirement
|
276
|
-
none: false
|
277
|
-
requirements:
|
278
|
-
- - ! '>='
|
279
|
-
- !ruby/object:Gem::Version
|
280
|
-
version: '0'
|
281
|
-
type: :development
|
282
|
-
prerelease: false
|
283
|
-
version_requirements: !ruby/object:Gem::Requirement
|
284
|
-
none: false
|
285
|
-
requirements:
|
286
|
-
- - ! '>='
|
287
|
-
- !ruby/object:Gem::Version
|
288
|
-
version: '0'
|
289
273
|
- !ruby/object:Gem::Dependency
|
290
274
|
name: factory_girl_rails
|
291
275
|
requirement: !ruby/object:Gem::Requirement
|
@@ -863,6 +847,7 @@ files:
|
|
863
847
|
- spec/dummy/config/initializers/session_store.rb
|
864
848
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
865
849
|
- spec/dummy/config/locales/en.yml
|
850
|
+
- spec/dummy/config/locales/fo.yml
|
866
851
|
- spec/dummy/config/routes.rb
|
867
852
|
- spec/dummy/db/schema.rb
|
868
853
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -917,6 +902,7 @@ files:
|
|
917
902
|
- spec/spec_helper.rb
|
918
903
|
- spec/support/alchemy/controller_hacks.rb
|
919
904
|
- spec/support/alchemy/specs_helpers.rb
|
905
|
+
- spec/support/alchemy/test_tweaks.rb
|
920
906
|
- vendor/assets/javascripts/jquery_plugins/jquery.Jcrop.min.js
|
921
907
|
- vendor/assets/javascripts/jquery_plugins/jquery.dialogextend.min.js
|
922
908
|
- vendor/assets/javascripts/jquery_plugins/jquery.html5uploader.js
|
@@ -1039,7 +1025,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1039
1025
|
version: '0'
|
1040
1026
|
segments:
|
1041
1027
|
- 0
|
1042
|
-
hash: -
|
1028
|
+
hash: -3671524832789070109
|
1043
1029
|
requirements:
|
1044
1030
|
- ImageMagick (libmagick), v6.6 or greater.
|
1045
1031
|
rubyforge_project:
|
@@ -1085,6 +1071,7 @@ test_files:
|
|
1085
1071
|
- spec/dummy/config/initializers/session_store.rb
|
1086
1072
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
1087
1073
|
- spec/dummy/config/locales/en.yml
|
1074
|
+
- spec/dummy/config/locales/fo.yml
|
1088
1075
|
- spec/dummy/config/routes.rb
|
1089
1076
|
- spec/dummy/db/schema.rb
|
1090
1077
|
- spec/dummy/lib/assets/.gitkeep
|
@@ -1139,4 +1126,5 @@ test_files:
|
|
1139
1126
|
- spec/spec_helper.rb
|
1140
1127
|
- spec/support/alchemy/controller_hacks.rb
|
1141
1128
|
- spec/support/alchemy/specs_helpers.rb
|
1129
|
+
- spec/support/alchemy/test_tweaks.rb
|
1142
1130
|
has_rdoc:
|