spud_core 0.8.18 → 0.8.19
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/app/controllers/spud/application_controller.rb +6 -2
- data/app/helpers/spud/admin/application_helper.rb +0 -9
- data/app/views/layouts/spud/admin/detail.html.erb +1 -1
- data/lib/spud_core/configuration.rb +24 -9
- data/lib/spud_core/version.rb +1 -1
- data/spec/controllers/spud/application_controller_spec.rb +33 -9
- data/spec/dummy/log/development.log +37 -15
- data/spec/dummy/log/test.log +18907 -50617
- data/spec/lib/spud_core/configuration_spec.rb +36 -0
- metadata +6 -4
data/README.markdown
CHANGED
@@ -59,4 +59,5 @@ Spud uses RSpec for testing. Get the tests running with a few short commands:
|
|
59
59
|
After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
|
60
60
|
|
61
61
|
|
62
|
+
NOTE: Spud Core is Retina Resolution Compatible Now
|
62
63
|
|
@@ -1,12 +1,11 @@
|
|
1
1
|
class Spud::ApplicationController < ActionController::Base
|
2
2
|
unloadable
|
3
3
|
protect_from_forgery
|
4
|
-
helper_method :current_user_session, :current_user, :current_site_name
|
4
|
+
helper_method :current_user_session, :current_user, :current_site_name, :current_site_id
|
5
5
|
around_filter :set_time_zone
|
6
6
|
around_filter :multisite_caching
|
7
7
|
before_filter :to
|
8
8
|
|
9
|
-
|
10
9
|
def current_site_name
|
11
10
|
# puts "request.host_with_port = #{request.host_with_port}"
|
12
11
|
return Spud::Core.site_name if !Spud::Core.multisite_mode_enabled
|
@@ -16,6 +15,11 @@ class Spud::ApplicationController < ActionController::Base
|
|
16
15
|
return config[:site_name]
|
17
16
|
end
|
18
17
|
|
18
|
+
def current_site_id
|
19
|
+
config = Spud::Core.site_config_for_host(request.host_with_port)
|
20
|
+
return config[:site_id] unless config.blank?
|
21
|
+
end
|
22
|
+
|
19
23
|
private
|
20
24
|
|
21
25
|
def to
|
@@ -1,14 +1,5 @@
|
|
1
1
|
module Spud::Admin::ApplicationHelper
|
2
2
|
|
3
|
-
def hidpi_asset(path)
|
4
|
-
begin
|
5
|
-
return nil if Rails.application.assets.find_asset(path.gsub(/\.png/,"@2x.png")).nil?
|
6
|
-
asset_path = asset_path(path.gsub(/\.png/,"@2x.png"))
|
7
|
-
return asset_path
|
8
|
-
rescue
|
9
|
-
return nil
|
10
|
-
end
|
11
|
-
end
|
12
3
|
def timestamp(timedate=nil)
|
13
4
|
return "Never" if timedate.blank?
|
14
5
|
return Time.now() - timedate > 604800 ? timedate.strftime("%B %d") + ' at ' + timedate.strftime("%I:%M %p") : time_ago_in_words(timedate) + ' ago'
|
@@ -1,21 +1,36 @@
|
|
1
1
|
module Spud
|
2
2
|
module Core
|
3
3
|
include ActiveSupport::Configurable
|
4
|
-
config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address
|
4
|
+
config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address,:site_id,:short_name
|
5
5
|
self.admin_applications = [{:name => "Users",:thumbnail => "spud/admin/users_thumb.png",:url => "/spud/admin/users",:order => 100}]
|
6
6
|
self.site_name = "Company Name"
|
7
|
+
self.site_id = 0
|
8
|
+
self.short_name = 'default'
|
7
9
|
self.sitemap_urls = []
|
8
10
|
self.multisite_mode_enabled = false
|
9
11
|
self.multisite_config = []
|
10
12
|
self.from_address = "no-reply@spudengine.com"
|
13
|
+
|
11
14
|
def self.site_config_for_host(host)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
|
16
|
+
if configs.blank?
|
17
|
+
return default_site_config
|
18
|
+
else
|
19
|
+
return configs[0]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.site_config_for_id(id)
|
24
|
+
if(id == Spud::Core.config.site_id)
|
25
|
+
return self.default_site_config
|
26
|
+
else
|
27
|
+
matches = Spud::Core.config.multisite_config.select{ |site| site[:site_id] == id }
|
28
|
+
return matches[0] if matches.any?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.default_site_config
|
33
|
+
return {:site_id => Spud::Core.config.site_id, :site_name => Spud::Core.config.site_name, :short_name => Spud::Core.config.short_name}
|
34
|
+
end
|
20
35
|
end
|
21
36
|
end
|
data/lib/spud_core/version.rb
CHANGED
@@ -2,21 +2,18 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Spud::ApplicationController do
|
4
4
|
|
5
|
-
|
6
5
|
before :each do
|
7
6
|
activate_authlogic
|
8
7
|
@user = FactoryGirl.create(:spud_user)
|
9
8
|
@session = SpudUserSession.create(@user)
|
10
9
|
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def index
|
17
|
-
render :nothing => true
|
18
|
-
end
|
11
|
+
describe :current_site_name do
|
12
|
+
controller(Spud::ApplicationController) do
|
13
|
+
def index
|
14
|
+
render :nothing => true
|
19
15
|
end
|
16
|
+
end
|
20
17
|
it "should return config site name if multisite is disabled" do
|
21
18
|
Spud::Core.configure do |config|
|
22
19
|
config.site_name = "Test Site"
|
@@ -36,14 +33,41 @@ describe Spud::ApplicationController do
|
|
36
33
|
Spud::Core.configure do |config|
|
37
34
|
config.site_name = "Test Site"
|
38
35
|
config.multisite_mode_enabled = true
|
39
|
-
config.multisite_config += [{:hosts => ["test.host"]
|
36
|
+
config.multisite_config += [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
|
40
37
|
end
|
41
38
|
|
42
39
|
# puts request.host_with_port
|
43
40
|
# helper.request = {:host_with_port => "example.com"}
|
44
41
|
@controller.request = request
|
45
42
|
@controller.current_site_name.should == 'Site B'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe :current_site_id do
|
47
|
+
|
48
|
+
controller(Spud::ApplicationController) do
|
49
|
+
def index
|
50
|
+
render :nothing => true
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
54
|
+
it "should return the default site id if multisite is disabled" do
|
55
|
+
Spud::Core.configure do |config|
|
56
|
+
config.site_id = 0
|
57
|
+
config.multisite_mode_enabled = false
|
58
|
+
config.multisite_config = []
|
59
|
+
end
|
60
|
+
@controller.current_site_id.should == 0
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should return the current site id if multisite is enabled" do
|
64
|
+
Spud::Core.configure do |config|
|
65
|
+
config.multisite_mode_enabled = true
|
66
|
+
config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
|
67
|
+
end
|
68
|
+
@controller.request = request
|
69
|
+
@controller.current_site_id.should == 1
|
70
|
+
end
|
71
|
+
|
48
72
|
end
|
49
73
|
end
|
@@ -1,17 +1,39 @@
|
|
1
1
|
Connecting to database specified by database.yml
|
2
|
-
[1m[36m (
|
3
|
-
[1m[35m (
|
2
|
+
[1m[36m (65.4ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB[0m
|
3
|
+
[1m[35m (144.1ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
4
|
+
[1m[36m (0.3ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
|
5
|
+
Migrating to CreateSpudAdminPermissions (20111214161011)
|
6
|
+
[1m[35m (103.8ms)[0m CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
|
7
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20111214161011')[0m
|
8
|
+
Migrating to CreateSpudUsers (20111214161146)
|
9
|
+
[1m[35m (113.1ms)[0m CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
|
10
|
+
[1m[36m (117.7ms)[0m [1mCREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)[0m
|
11
|
+
[1m[35m (111.0ms)[0m CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
|
12
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20111214161146')[0m
|
13
|
+
Migrating to AddTimeZoneToSpudUser (20120327124229)
|
14
|
+
[1m[35m (149.1ms)[0m ALTER TABLE `spud_users` ADD `time_zone` varchar(255)
|
15
|
+
[1m[36m (0.5ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120327124229')[0m
|
16
|
+
Migrating to AddScopeToSpudAdminPermissions (20120328235431)
|
17
|
+
[1m[35m (130.5ms)[0m ALTER TABLE `spud_admin_permissions` ADD `scope` varchar(255)
|
18
|
+
[1m[36m (0.5ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120328235431')[0m
|
19
|
+
Migrating to CreateSpudUserSettings (20120329174000)
|
20
|
+
[1m[35m (105.9ms)[0m CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
|
21
|
+
[1m[36m (0.8ms)[0m [1mINSERT INTO `schema_migrations` (`version`) VALUES ('20120329174000')[0m
|
22
|
+
[1m[35m (0.3ms)[0m SELECT `schema_migrations`.`version` FROM `schema_migrations`
|
23
|
+
Connecting to database specified by database.yml
|
24
|
+
[1m[36m (0.3ms)[0m [1mSELECT `schema_migrations`.`version` FROM `schema_migrations` [0m
|
25
|
+
[1m[35m (0.5ms)[0m DROP DATABASE IF EXISTS `spud_core_test`
|
4
26
|
[1m[36m (0.3ms)[0m [1mCREATE DATABASE `spud_core_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`[0m
|
5
|
-
[1m[35m (
|
6
|
-
[1m[36m (
|
7
|
-
[1m[35m (
|
8
|
-
[1m[36m (
|
9
|
-
[1m[35m (
|
10
|
-
[1m[36m (
|
11
|
-
[1m[35m (
|
12
|
-
[1m[36m (0.
|
13
|
-
[1m[35m (
|
14
|
-
[1m[36m (0.
|
15
|
-
[1m[35m (0.
|
16
|
-
[1m[36m (0.
|
17
|
-
[1m[35m (0.
|
27
|
+
[1m[35m (54.2ms)[0m CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `scope` varchar(255)) ENGINE=InnoDB
|
28
|
+
[1m[36m (177.3ms)[0m [1mCREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB[0m
|
29
|
+
[1m[35m (191.0ms)[0m CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `time_zone` varchar(255)) ENGINE=InnoDB
|
30
|
+
[1m[36m (105.0ms)[0m [1mCREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)[0m
|
31
|
+
[1m[35m (100.1ms)[0m CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
|
32
|
+
[1m[36m (115.5ms)[0m [1mCREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB[0m
|
33
|
+
[1m[35m (127.3ms)[0m CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
|
34
|
+
[1m[36m (0.3ms)[0m [1mSELECT version FROM `schema_migrations`[0m
|
35
|
+
[1m[35m (0.6ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20120329174000')
|
36
|
+
[1m[36m (0.4ms)[0m [1mINSERT INTO `schema_migrations` (version) VALUES ('20111214161011')[0m
|
37
|
+
[1m[35m (0.4ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20111214161146')
|
38
|
+
[1m[36m (0.4ms)[0m [1mINSERT INTO `schema_migrations` (version) VALUES ('20120327124229')[0m
|
39
|
+
[1m[35m (0.3ms)[0m INSERT INTO `schema_migrations` (version) VALUES ('20120328235431')
|