authengine 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/README.md +86 -0
- data/Rakefile +31 -0
- data/app/assets/images/message_block/back.gif +0 -0
- data/app/assets/images/message_block/back_m.gif +0 -0
- data/app/assets/images/message_block/confirmation.gif +0 -0
- data/app/assets/images/message_block/confirmation_m.gif +0 -0
- data/app/assets/images/message_block/error.gif +0 -0
- data/app/assets/images/message_block/error_m.gif +0 -0
- data/app/assets/images/message_block/info.gif +0 -0
- data/app/assets/images/message_block/info_m.gif +0 -0
- data/app/assets/images/message_block/notice.gif +0 -0
- data/app/assets/images/message_block/notice_m.gif +0 -0
- data/app/assets/images/message_block/warn.gif +0 -0
- data/app/assets/images/message_block/warn_m.gif +0 -0
- data/app/assets/stylesheets/authengine.css +3 -0
- data/app/assets/stylesheets/message_block.css +45 -0
- data/app/controllers/authengine/accounts_controller.rb +56 -0
- data/app/controllers/authengine/action_roles_controller.rb +22 -0
- data/app/controllers/authengine/actions_controller.rb +17 -0
- data/app/controllers/authengine/roles_controller.rb +35 -0
- data/app/controllers/authengine/sessions_controller.rb +75 -0
- data/app/controllers/authengine/user_roles_controller.rb +55 -0
- data/app/controllers/authengine/useractions_controller.rb +17 -0
- data/app/controllers/authengine/users_controller.rb +137 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/authengine/users_helper.rb +11 -0
- data/app/helpers/roles_helper.rb +2 -0
- data/app/mailers/authengine/user_mailer.rb +53 -0
- data/app/models/action.rb +54 -0
- data/app/models/action_role.rb +29 -0
- data/app/models/authenticated_system.rb +179 -0
- data/app/models/authorized_system.rb +41 -0
- data/app/models/controller.rb +124 -0
- data/app/models/role.rb +71 -0
- data/app/models/session.rb +3 -0
- data/app/models/session_role.rb +17 -0
- data/app/models/user.rb +191 -0
- data/app/models/user_observer.rb +14 -0
- data/app/models/user_role.rb +4 -0
- data/app/models/useraction.rb +56 -0
- data/app/views/authengine/accounts/edit.html.erb +19 -0
- data/app/views/authengine/actions/create.html.erb +2 -0
- data/app/views/authengine/actions/destroy.html.erb +2 -0
- data/app/views/authengine/actions/edit.html.erb +80 -0
- data/app/views/authengine/actions/index.html.haml +26 -0
- data/app/views/authengine/actions/new.html.erb +2 -0
- data/app/views/authengine/actions/show.html.erb +8 -0
- data/app/views/authengine/actions/update.html.erb +11 -0
- data/app/views/authengine/admin/_show.html.haml +5 -0
- data/app/views/authengine/layouts/authengine.html.haml +9 -0
- data/app/views/authengine/roles/index.html.haml +12 -0
- data/app/views/authengine/roles/new.html.haml +15 -0
- data/app/views/authengine/roles/show.html.erb +8 -0
- data/app/views/authengine/sessions/new.html.haml +18 -0
- data/app/views/authengine/user_mailer/activation.html.erb +5 -0
- data/app/views/authengine/user_mailer/forgot_password.html.erb +3 -0
- data/app/views/authengine/user_mailer/message_to_admin.html.erb +2 -0
- data/app/views/authengine/user_mailer/reset_password.html.erb +1 -0
- data/app/views/authengine/user_mailer/signup_notification.html.erb +5 -0
- data/app/views/authengine/user_roles/edit.html.haml +10 -0
- data/app/views/authengine/user_roles/index.html.haml +14 -0
- data/app/views/authengine/user_roles/new.html.haml +8 -0
- data/app/views/authengine/useractions/_useraction.html.erb +6 -0
- data/app/views/authengine/useractions/index.html.erb +13 -0
- data/app/views/authengine/useractions/show.html.haml +14 -0
- data/app/views/authengine/useractions/update.html.erb +2 -0
- data/app/views/authengine/users/_no_privacy_policy.html.haml +1 -0
- data/app/views/authengine/users/_privacy_policy_example.html.haml +36 -0
- data/app/views/authengine/users/_user.html.haml +19 -0
- data/app/views/authengine/users/edit.html.haml +24 -0
- data/app/views/authengine/users/index.html.haml +10 -0
- data/app/views/authengine/users/new.html.haml +31 -0
- data/app/views/authengine/users/show.html.haml +19 -0
- data/app/views/authengine/users/signup.html.haml +52 -0
- data/authengine.gemspec +44 -0
- data/config/application.rb +1 -0
- data/config/routes.rb +43 -0
- data/db/migrate/20110320171029_create_authengine_tables.rb +90 -0
- data/db/migrate/20110924165900_add_parent_id_to_roles_table.rb +5 -0
- data/db/migrate/20110925202800_add_type_field_to_user_roles_table.rb +5 -0
- data/db/migrate/20111003074700_add_indexes_to_several_tables.rb +7 -0
- data/db/seeds.rb +7 -0
- data/lib/application_helper.rb +19 -0
- data/lib/authengine.rb +5 -0
- data/lib/authengine/engine.rb +44 -0
- data/lib/authengine/testing_support/factories/user_factory.rb +13 -0
- data/lib/authengine/version.rb +3 -0
- data/lib/rails/generators/authengine/authengine_generator.rb +160 -0
- data/lib/rails/generators/authengine/templates/initializer.rb +3 -0
- data/lib/rails/generators/authengine/templates/migration.rb +16 -0
- data/lib/rails/generators/authengine/templates/pre_populate_database.rb +20 -0
- data/lib/rails/generators/authengine/templates/schema.rb +69 -0
- data/lib/tasks/bootstrap.rake +29 -0
- data/spec/authengine_spec.rb +7 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/Gemfile +3 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/javascripts/jasmine_examples/Player.js +22 -0
- data/spec/dummy/app/assets/javascripts/jasmine_examples/Song.js +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +50 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/application.rb +1 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +87 -0
- data/spec/dummy/lib/constants.rb +5 -0
- data/spec/dummy/log/development.log +117 -0
- data/spec/dummy/log/production.log +0 -0
- data/spec/dummy/log/server.log +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/dummy/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/spec/dummy/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/spec/dummy/spec/javascripts/support/jasmine.yml +76 -0
- data/spec/generators/authengine_generator_spec.rb +11 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/javascripts/spec.css +3 -0
- data/spec/javascripts/spec.js.coffee +2 -0
- data/spec/models/action_role_spec.rb +59 -0
- data/spec/models/authenticated_system_spec.rb +109 -0
- data/spec/models/role_spec.rb +38 -0
- data/spec/models/user_factory_spec.rb +7 -0
- data/spec/models/user_spec.rb +16 -0
- data/spec/requests/sessions_spec.rb +11 -0
- data/spec/spec_helper.rb +57 -0
- metadata +405 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'faker'
|
2
|
+
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :user do
|
5
|
+
login {Faker::Name.last_name}
|
6
|
+
email {Faker::Internet.email}
|
7
|
+
activated_at {Date.today - rand(365)}
|
8
|
+
enabled 1
|
9
|
+
firstName {Faker::Name.first_name}
|
10
|
+
lastName {Faker::Name.last_name}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class AuthengineGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname) #:nodoc:
|
12
|
+
if ActiveRecord::Base.timestamped_migrations
|
13
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# Every method that is declared below will be automatically executed when the generator is run
|
21
|
+
|
22
|
+
def create_migration_file
|
23
|
+
prepare_migration_directory
|
24
|
+
remove_previous_migration
|
25
|
+
|
26
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
|
27
|
+
schema = f.read; f.close
|
28
|
+
|
29
|
+
schema.gsub!(/ActiveRecord::Schema.*\n/, '')
|
30
|
+
schema.gsub!(/^end\n*$/, '')
|
31
|
+
|
32
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
|
33
|
+
migration = f.read; f.close
|
34
|
+
migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
|
35
|
+
|
36
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'pre_populate_database.rb')
|
37
|
+
pre_populate = f.read; f.close
|
38
|
+
migration.gsub!(/DATABASE_PREPOPULATE/, pre_populate)
|
39
|
+
|
40
|
+
tmp = File.open "tmp/~migration_ready.rb", "w"
|
41
|
+
tmp.write migration
|
42
|
+
tmp.close
|
43
|
+
|
44
|
+
if !File.exists?(File.join(Rails.root,'db','migrate'))
|
45
|
+
FileUtils.makedirs(File.join(Rails.root, 'db', 'migrate'))
|
46
|
+
end
|
47
|
+
migration_template '../../../tmp/~migration_ready.rb', 'db/migrate/create_authengine_tables.rb'
|
48
|
+
remove_file 'tmp/~migration_ready.rb'
|
49
|
+
end
|
50
|
+
|
51
|
+
def copy_initializer_file
|
52
|
+
copy_file 'initializer.rb', 'config/initializers/authengine.rb'
|
53
|
+
end
|
54
|
+
|
55
|
+
def update_application_template
|
56
|
+
case
|
57
|
+
when layout.unmodified?
|
58
|
+
|
59
|
+
print " \e[1m\e[34mquestion\e[0m Your layouts/#{application_layout_file} layout currently has the line <%= yield %>. This gem needs to change this line to <%= content_for?(:content) ? yield(:content) : yield %> to support its nested layouts. This change should not affect any of your existing layouts or views. Is this okay? [y/n] "
|
60
|
+
begin
|
61
|
+
answer = gets.chomp
|
62
|
+
end while not answer =~ /[yn]/i
|
63
|
+
|
64
|
+
if answer =~ /y/i
|
65
|
+
|
66
|
+
case
|
67
|
+
when application_layout_file.erb?
|
68
|
+
layout.gsub!(/<%=[ ]+yield[ ]+%>/, '<%= content_for?(:content) ? yield(:content) : yield %>')
|
69
|
+
tmp = File.open "tmp/~application.html.erb", "w"
|
70
|
+
tmp.write layout; tmp.close
|
71
|
+
|
72
|
+
remove_file 'app/views/layouts/application.html.erb'
|
73
|
+
copy_file '../../../tmp/~application.html.erb', 'app/views/layouts/application.html.erb'
|
74
|
+
remove_file 'tmp/~application.html.erb'
|
75
|
+
when application_layout_file.haml?
|
76
|
+
layout.gsub!(/=\s*yield/, haml_yield_string)
|
77
|
+
tmp = File.open "tmp/~application.html.haml", "w"
|
78
|
+
tmp.write layout; tmp.close
|
79
|
+
|
80
|
+
remove_file 'app/views/layouts/application.html.haml'
|
81
|
+
copy_file '../../../tmp/~application.html.haml', 'app/views/layouts/application.html.haml'
|
82
|
+
remove_file 'tmp/~application.html.haml'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
when layout.modified?
|
87
|
+
puts " \e[1m\e[33mskipping\e[0m layouts/#{application_layout_file} modification is already done."
|
88
|
+
else
|
89
|
+
puts " \e[1m\e[31mconflict\e[0m The gem is confused by your layouts/#{application_layout_file}. It does not contain the default line <%= yield %>, you may need to make manual changes to get this gem's nested layouts working. Visit ###### for details."
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
# a fresh rails application does not have a db/migrate directory
|
95
|
+
def prepare_migration_directory
|
96
|
+
FileUtils.makedirs(File.join(Rails.root, 'db', 'migrate'))
|
97
|
+
end
|
98
|
+
|
99
|
+
# in case the generator is re-run, the migration is not duplicated
|
100
|
+
# instead the user is asked if (s)he wants to remove the previous migration
|
101
|
+
def remove_previous_migration
|
102
|
+
migrate_dir = Dir.new(File.join(Rails.root, 'db', 'migrate'))
|
103
|
+
if migration = migrate_dir.entries.detect{|f| f.match(/_create_authengine_tables.rb/)}
|
104
|
+
print " \e[1m\e[34mquestion\e[0m A migration file called #{migration} already exists. Do you wish to overwrite it? [y/n] "
|
105
|
+
begin
|
106
|
+
answer = gets.chomp
|
107
|
+
end while not answer =~ /[yn]/i
|
108
|
+
|
109
|
+
if answer =~ /y/i
|
110
|
+
File.delete(File.join(Rails.root, 'db', 'migrate', migration))
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def layout
|
116
|
+
f = File.open File.join("app", "views", "layouts", application_layout_file)
|
117
|
+
@contents ||= f.read # otherwise every time we call layout, it re-reads the file!
|
118
|
+
|
119
|
+
def @contents.unmodified?
|
120
|
+
stripped_contents = self.gsub(/\s*/,'')
|
121
|
+
match_haml = !(stripped_contents =~ /=yield/).nil?
|
122
|
+
match_erb = !(stripped_contents =~ /<%=yield%>/).nil?
|
123
|
+
match_haml || match_erb
|
124
|
+
end
|
125
|
+
|
126
|
+
def @contents.modified?
|
127
|
+
stripped_contents = self.gsub(/\s*/,'')
|
128
|
+
match_haml = !(stripped_contents =~ /-content_for\?\(:content\)\?=yield\(:content\):=yield/).nil?
|
129
|
+
match_erb = !(stripped_contents =~ /<%=content_for\?\(:content\)\?yield\(:content\):yield%>/).nil?
|
130
|
+
match_haml || match_erb
|
131
|
+
end
|
132
|
+
|
133
|
+
f.close
|
134
|
+
@contents
|
135
|
+
end
|
136
|
+
|
137
|
+
def haml_yield_string
|
138
|
+
"= content_for?(:content) ? yield(:content) : yield"
|
139
|
+
end
|
140
|
+
|
141
|
+
def erb_yield_string
|
142
|
+
"<%#{haml_yield_string} %>"
|
143
|
+
end
|
144
|
+
|
145
|
+
def application_layout_file
|
146
|
+
file = Dir.new("app/views/layouts").entries.detect{|f| f =~ /^application/ }
|
147
|
+
|
148
|
+
def file.haml?
|
149
|
+
!(self =~ /haml$/).nil?
|
150
|
+
end
|
151
|
+
|
152
|
+
def file.erb?
|
153
|
+
!(self =~ /erb$/).nil?
|
154
|
+
end
|
155
|
+
|
156
|
+
file
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateAuthengineTables < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
SCHEMA_AUTO_INSERTED_HERE
|
4
|
+
DATABASE_PREPOPULATE
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
drop_table :useractions
|
9
|
+
drop_table :user_roles
|
10
|
+
drop_table :roles
|
11
|
+
drop_table :controllers
|
12
|
+
drop_table :action_roles
|
13
|
+
drop_table :actions
|
14
|
+
drop_table :users
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
User.reset_column_information
|
2
|
+
user = User.create(:login => 'admin',
|
3
|
+
:email => 'user@example.com',
|
4
|
+
:enabled => true,
|
5
|
+
:firstName => 'A',
|
6
|
+
:lastName => 'User')
|
7
|
+
user.update_attribute(:salt, '1641b615ad281759adf85cd5fbf17fcb7a3f7e87')
|
8
|
+
user.update_attribute(:activation_code, '9bb0db48971821563788e316b1fdd53dd99bc8ff')
|
9
|
+
user.update_attribute(:activated_at, DateTime.new(2011,1,1))
|
10
|
+
user.update_attribute(:crypted_password, '660030f1be7289571b0467b9195ff39471c60651')
|
11
|
+
|
12
|
+
# in the bootstrap scenario, give the administrative user enough
|
13
|
+
# access to be able to configure the access tables for admin and other users
|
14
|
+
role = Role.create(:name => 'developer')
|
15
|
+
Controller.update_table
|
16
|
+
Action.all.each { |a| role.actions << a }
|
17
|
+
user.roles << role
|
18
|
+
user.save
|
19
|
+
|
20
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
ActiveRecord::Schema.define(:version => 20110403132035) do
|
2
|
+
|
3
|
+
create_table "action_roles", :force => true do |t|
|
4
|
+
t.integer "role_id", :limit => 8
|
5
|
+
t.integer "action_id", :limit => 8
|
6
|
+
t.datetime "created_at"
|
7
|
+
t.datetime "updated_at"
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table "actions", :force => true do |t|
|
11
|
+
t.string "action_name"
|
12
|
+
t.integer "controller_id"
|
13
|
+
t.datetime "created_at"
|
14
|
+
t.datetime "updated_at"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
create_table "controllers", :force => true do |t|
|
19
|
+
t.string "controller_name"
|
20
|
+
t.datetime "last_modified"
|
21
|
+
t.datetime "created_at"
|
22
|
+
t.datetime "updated_at"
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
create_table "roles", :force => true do |t|
|
27
|
+
t.string "name"
|
28
|
+
t.string "short_name"
|
29
|
+
t.datetime "created_at"
|
30
|
+
t.datetime "updated_at"
|
31
|
+
end
|
32
|
+
|
33
|
+
create_table "user_roles", :force => true do |t|
|
34
|
+
t.integer "role_id", :limit => 8, :null => false
|
35
|
+
t.integer "user_id", :limit => 8, :null => false
|
36
|
+
t.datetime "created_at"
|
37
|
+
t.datetime "updated_at"
|
38
|
+
end
|
39
|
+
|
40
|
+
create_table "useractions", :force => true do |t|
|
41
|
+
t.integer "user_id"
|
42
|
+
t.integer "action_id"
|
43
|
+
t.string "type"
|
44
|
+
t.text "params"
|
45
|
+
t.datetime "created_at"
|
46
|
+
t.datetime "updated_at"
|
47
|
+
end
|
48
|
+
|
49
|
+
create_table "users", :force => true do |t|
|
50
|
+
t.string "login"
|
51
|
+
t.string "email"
|
52
|
+
t.string "crypted_password", :limit => 40
|
53
|
+
t.string "salt", :limit => 40
|
54
|
+
t.string "remember_token"
|
55
|
+
t.datetime "remember_token_expires_at"
|
56
|
+
t.string "activation_code", :limit => 40
|
57
|
+
t.datetime "activated_at"
|
58
|
+
t.string "password_reset_code", :limit => 40
|
59
|
+
t.boolean "enabled", :default => true
|
60
|
+
t.string "firstName"
|
61
|
+
t.string "lastName"
|
62
|
+
t.string "type"
|
63
|
+
t.string "status"
|
64
|
+
t.datetime "created_at"
|
65
|
+
t.datetime "updated_at"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
namespace :authengine do
|
2
|
+
desc 'create an admin access account, only when there are no accounts already configured. Call rake authengine:bootstrap[firstname,lastname,login,password] (no spaces, no quotes)'
|
3
|
+
task :bootstrap, [:firstName, :lastName, :login, :password] => :environment do |t, args|
|
4
|
+
if args.to_hash.keys.length < 4
|
5
|
+
puts "Please specify firstname, lastname, login and password"
|
6
|
+
else
|
7
|
+
if User.count > 0
|
8
|
+
puts "There is already a user account present, you may only bootstrap the first account"
|
9
|
+
else
|
10
|
+
attributes = {:firstName => args[:firstName],
|
11
|
+
:lastName => args[:lastName],
|
12
|
+
:login => args[:login],
|
13
|
+
:password => args[:password],
|
14
|
+
:password_confirmation => args[:password]}
|
15
|
+
if id = User.create_by_sql(attributes)
|
16
|
+
puts "Creating account for #{attributes[:firstName]} #{attributes[:lastName]} login: #{attributes[:login]}, password #{attributes[:password]}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if
|
22
|
+
user = User.find(id)
|
23
|
+
role = Role.create(:name => 'admin')
|
24
|
+
user.roles << role
|
25
|
+
Controller.update_table
|
26
|
+
ActionRole.bootstrap_access_for(role)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/dummy/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/dummy/Gemfile
ADDED
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
8
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
function Player() {
|
2
|
+
}
|
3
|
+
Player.prototype.play = function(song) {
|
4
|
+
this.currentlyPlayingSong = song;
|
5
|
+
this.isPlaying = true;
|
6
|
+
};
|
7
|
+
|
8
|
+
Player.prototype.pause = function() {
|
9
|
+
this.isPlaying = false;
|
10
|
+
};
|
11
|
+
|
12
|
+
Player.prototype.resume = function() {
|
13
|
+
if (this.isPlaying) {
|
14
|
+
throw new Error("song is already playing");
|
15
|
+
}
|
16
|
+
|
17
|
+
this.isPlaying = true;
|
18
|
+
};
|
19
|
+
|
20
|
+
Player.prototype.makeFavorite = function() {
|
21
|
+
this.currentlyPlayingSong.persistFavoriteStatus(true);
|
22
|
+
};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "authengine"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
|
45
|
+
config.generators do |g|
|
46
|
+
# Configure haml to be the default templating engine for generators
|
47
|
+
g.template_engine :haml
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|