Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed namespacing inconsistencies around Role and RolesUsers etc.

  • Loading branch information...
commit b4fe769a826d9346facf76b01186360c55f8dca4 1 parent b6fa9b2
@parndt parndt authored
View
6 authentication/app/controllers/refinery/admin/users_controller.rb
@@ -26,7 +26,7 @@ def create
unless current_refinery_user.has_role?(:superuser) and ::Refinery::Setting.find_or_set(:superuser_can_assign_roles, false)
@user.add_role(:refinery)
else
- @user.roles = @selected_role_names.collect{|r| Role[r.downcase.to_sym]}
+ @user.roles = @selected_role_names.collect{|r| ::Refinery::Role[r.downcase.to_sym]}
end
redirect_to(main_app.refinery_admin_users_path, :notice => t('created', :what => @user.username, :scope => 'refinery.crudify'))
@@ -56,7 +56,7 @@ def update
# Store the current plugins and roles for this user.
@previously_selected_plugin_names = @user.plugins.collect{|p| p.name}
@previously_selected_roles = @user.roles
- @user.roles = @selected_role_names.collect{|r| Role[r.downcase.to_sym]}
+ @user.roles = @selected_role_names.collect{|r| ::Refinery::Role[r.downcase.to_sym]}
if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
params[:user].except!(:password, :password_confirmation)
end
@@ -80,7 +80,7 @@ def load_available_plugins_and_roles
{:name => a.name, :title => a.title}
}.sort_by {|a| a[:title]}
- @available_roles = Role.all
+ @available_roles =::Refinery::Role.all
end
end
View
6 authentication/app/controllers/refinery/registrations_controller.rb
@@ -21,7 +21,7 @@ def create
@user.add_role(:refinery)
@user.plugins = @selected_plugin_titles
@user.save
- if Role[:refinery].users.count == 1
+ if ::Refinery::Role[:refinery].users.count == 1
# this is the superuser if this user is the only user.
@user.add_role(:superuser)
@user.save
@@ -39,7 +39,7 @@ def create
flash[:message] = "<h2>#{t('welcome', :scope => 'refinery.users.create', :who => @user.username).gsub(/\.$/, '')}.</h2>".html_safe
site_name_setting = ::Refinery::Setting.find_or_create_by_name('site_name', :value => "Company Name")
- if site_name_setting.value.to_s =~ /^(|Company\ Name)$/ or Role[:refinery].users.count == 1
+ if site_name_setting.value.to_s =~ /^(|Company\ Name)$/ or ::Refinery::Role[:refinery].users.count == 1
flash[:message] << "<p>#{t('setup_website_name_html', :scope => 'refinery.users',
:link => main_app.edit_refinery_admin_setting_path(site_name_setting, :dialog => true),
:title => t('edit', :scope => 'refinery.admin.settings'))}</p>".html_safe
@@ -62,7 +62,7 @@ def redirect?
end
def refinery_users_exist?
- Role[:refinery].users.any?
+ ::Refinery::Role[:refinery].users.any?
end
end
View
4 authentication/app/controllers/refinery/users_controller.rb
@@ -18,7 +18,7 @@ def create
flash[:message] = "<h2>#{t('welcome', :scope => 'refinery.users.create', :who => @user.username).gsub(/\.$/, '')}.</h2>".html_safe
site_name_setting = ::Refinery::Setting.find_or_create_by_name('site_name', :value => "Company Name")
- if site_name_setting.value.to_s =~ /^(|Company\ Name)$/ or Role[:refinery].users.count == 1
+ if site_name_setting.value.to_s =~ /^(|Company\ Name)$/ or ::Refinery::Role[:refinery].users.count == 1
flash[:message] << "<p>#{
t('setup_website_name_html', :scope => 'refinery.users',
:link => main_app.edit_refinery_admin_setting_path(site_name_setting, :dialog => true),
@@ -43,7 +43,7 @@ def redirect?
end
def refinery_users_exist?
- Role[:refinery].users.any?
+ ::Refinery::Role[:refinery].users.any?
end
end
View
6 authentication/app/models/refinery/user.rb
@@ -46,13 +46,13 @@ def authorized_plugins
def can_delete?(user_to_delete = self)
user_to_delete.persisted? and
!user_to_delete.has_role?(:superuser) and
- Role[:refinery].users.count >= 1 and
+ ::Refinery::Role[:refinery].users.count >= 1 and
id != user_to_delete.id
end
def add_role(title)
raise ArgumentException, "Role should be the title of the role not a role object." if title.is_a?(Role)
- roles << Role[title] unless has_role?(title)
+ roles << ::Refinery::Role[title] unless has_role?(title)
end
def has_role?(title)
@@ -68,7 +68,7 @@ def create_first
# add refinery role
add_role(:refinery)
- if Role[:refinery].users.count == 1
+ if ::Refinery::Role[:refinery].users.count == 1
# this is the superuser if this user is the only user.
add_role(:superuser)
View
4 authentication/db/migrate/20100913234705_create_refinerycms_authentication_schema.rb
@@ -1,12 +1,12 @@
class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
def self.up
# Postgres apparently requires the roles_users table to exist before creating the roles table.
- create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
+ create_table ::Refinery::RolesUsers.table_name, :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
- create_table ::Role.table_name, :force => true do |t|
+ create_table ::Refinery::Role.table_name, :force => true do |t|
t.string "title"
end
View
8 authentication/db/migrate/20100929035252_add_missing_indexes_to_roles_users.rb
@@ -1,11 +1,11 @@
class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
def self.up
- add_index ::RolesUsers.table_name, [:role_id, :user_id]
- add_index ::RolesUsers.table_name, [:user_id, :role_id]
+ add_index ::Refinery::RolesUsers.table_name, [:role_id, :user_id]
+ add_index ::Refinery::RolesUsers.table_name, [:user_id, :role_id]
end
def self.down
- remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id]
- remove_index ::RolesUsers.table_name, :column => [:user_id, :role_id]
+ remove_index ::Refinery::RolesUsers.table_name, :column => [:role_id, :user_id]
+ remove_index ::Refinery::RolesUsers.table_name, :column => [:user_id, :role_id]
end
end
View
8 authentication/spec/models/refinery/user_spec.rb
@@ -10,7 +10,7 @@ module Refinery
context "Roles" do
context "add_role" do
it "raises Exception when Role object is passed" do
- proc {user.add_role(Role.new)}.should raise_exception
+ proc {user.add_role(Refinery::Role.new)}.should raise_exception
end
it "adds a Role to the User when role not yet assigned to User" do
@@ -30,7 +30,7 @@ module Refinery
context "has_role" do
it "raises Exception when Role object is passed" do
- proc{ user.has_role?(Role.new)}.should raise_exception
+ proc{ user.has_role?(Refinery::Role.new)}.should raise_exception
end
it "returns the true if user has Role" do
@@ -96,7 +96,7 @@ module Refinery
end
it "if user count with refinery role < 1" do
- Role[:refinery].users.delete([ refinery_user, super_user ])
+ ::Refinery::Role[:refinery].users.delete([ refinery_user, super_user ])
super_user.can_delete?(refinery_user).should be_false
end
@@ -107,7 +107,7 @@ module Refinery
context "allow to delete" do
it "if user count with refinery role = 1" do
- Role[:refinery].users.delete(refinery_user)
+ ::Refinery::Role[:refinery].users.delete(refinery_user)
super_user.can_delete?(refinery_user).should be_true
end
View
6 changelog.md
@@ -255,7 +255,7 @@
## 0.9.8.8 [16 December 2010]
-* Prevented ::Refinery::RefinerySetting from accessing its database table before it is created. [Philip Arndt](https://github.com/parndt)
+* Prevented ::Refinery::Setting from accessing its database table before it is created. [Philip Arndt](https://github.com/parndt)
* Added more options to `bin/refinerycms` like ability to specify database username and password. [Philip Arndt](https://github.com/parndt)
* [See full list](https://github.com/resolve/refinerycms/compare/0.9.8.7...0.9.8.8)
@@ -417,7 +417,7 @@
* Documentation improved [David Jones](https://github.com/djones), [Philip Arndt](https://github.com/parndt) and [Steven Heidel](https://github.com/stevenheidel)
* Installed spork for use with systems that support forking for performance improvements. Doesn't run on Windows. [Philip Arndt](https://github.com/parndt) and [James Fiderlick](https://github.com/jamesfid)
* Improvements and new translations for Norsk Bokmål localisation. [Ken Paulsen](https://github.com/ken-guru)
-* Ensured that ::Refinery::RefinerySetting restrictions work properly using a before_save handler. [Joe Sak](https://github.com/joemsak)
+* Ensured that ::Refinery::Setting restrictions work properly using a before_save handler. [Joe Sak](https://github.com/joemsak)
* Updated jquery-html5-placeholder-shim to latest version. [Amanda Wagener](https://github.com/awagener)
* [See full list](https://github.com/resolve/refinerycms/compare/0.9.7.7...0.9.7.8)
@@ -493,7 +493,7 @@
* Marketable URLs, such as "/contact". [Joshua Davey](https://github.com/jgdavey) and [Joe Sak](https://github.com/joemsak).
* Switched to bundler and rack. [Alex Coles](https://github.com/myabc) and [Philip Arndt](https://github.com/parndt)
* Added options to Refinery Settings :restricted, :scoping, :callback_proc_as_string. [Steven Heidel](https://github.com/stevenheidel) and [Philip Arndt](https://github.com/parndt)
-* Added caching abilities to frontend and to ::Refinery::RefinerySetting to drastically speed up the application under certain conditions. [Philip Arndt](https://github.com/parndt)
+* Added caching abilities to frontend and to ::Refinery::Setting to drastically speed up the application under certain conditions. [Philip Arndt](https://github.com/parndt)
* Added spam filtering to contact form. [David Jones](https://github.com/djones)
* Full Refinery UI redesign. [Resolve Digital](https://github.com/resolve)
* User Role support. [Amanda Wagener](https://github.com/awagener) and [Philip Arndt](https://github.com/parndt)
View
2  core/lib/refinery/application_controller.rb
@@ -65,7 +65,7 @@ def home_page?
end
def just_installed?
- Role[:refinery].users.empty?
+ ::Refinery::Role[:refinery].users.empty?
end
def local_request?
Please sign in to comment.
Something went wrong with that request. Please try again.