extreme_aas 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rvmrc +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +134 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +25 -0
- data/app/models/extreme_aas/application_controller.rb +21 -0
- data/app/models/extreme_aas/extreme_action.rb +21 -0
- data/app/models/extreme_aas/extreme_action_abstract.rb +22 -0
- data/app/models/extreme_aas/extreme_action_edge.rb +6 -0
- data/app/models/extreme_aas/extreme_action_group.rb +33 -0
- data/app/models/extreme_aas/extreme_grant.rb +13 -0
- data/app/models/extreme_aas/extreme_profile.rb +10 -0
- data/app/models/extreme_aas/extreme_simple_action.rb +19 -0
- data/extreme_aas.gemspec +29 -0
- data/lib/extreme_aas/engine.rb +23 -0
- data/lib/extreme_aas/version.rb +3 -0
- data/lib/extreme_aas.rb +25 -0
- data/lib/generators/extreme_aas/extreme_aas_generator.rb +21 -0
- data/lib/generators/extreme_aas/templates/migration.rb +36 -0
- data/lib/tasks/sync.rake +56 -0
- data/spec/dummy/Gemfile.lock +10 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/users.js +2 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/assets/stylesheets/users.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/users_controller.rb +83 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/users_helper.rb +5 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/users/_form.html.erb +25 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +25 -0
- data/spec/dummy/app/views/users/new.html.erb +5 -0
- data/spec/dummy/app/views/users/show.html.erb +15 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +28 -0
- data/spec/dummy/config/database_template.yml +28 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/extreme_aas_groups.yml +0 -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 +60 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20120404105554_create_users.rb +10 -0
- data/spec/dummy/db/migrate/20120413132357_create_extreme_aas_tables.rb +36 -0
- data/spec/dummy/db/schema.rb +65 -0
- data/spec/dummy/public/401.html +26 -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 +202 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories.rb +26 -0
- data/spec/integration/controller_actions_spec.rb +28 -0
- data/spec/integration/navigation_spec.rb +8 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/extreme_aas_groups.yml +8 -0
- data/spec/unit/action_group_spec.rb +65 -0
- data/spec/unit/simple_action_spec.rb +34 -0
- metadata +235 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
(function() {
|
2
|
+
Ajax.Responders.register({
|
3
|
+
onCreate: function(request) {
|
4
|
+
var token = $$('meta[name=csrf-token]')[0];
|
5
|
+
if (token) {
|
6
|
+
if (!request.options.requestHeaders) request.options.requestHeaders = {};
|
7
|
+
request.options.requestHeaders['X-CSRF-Token'] = token.readAttribute('content');
|
8
|
+
}
|
9
|
+
}
|
10
|
+
});
|
11
|
+
|
12
|
+
// Technique from Juriy Zaytsev
|
13
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
14
|
+
function isEventSupported(eventName) {
|
15
|
+
var el = document.createElement('div');
|
16
|
+
eventName = 'on' + eventName;
|
17
|
+
var isSupported = (eventName in el);
|
18
|
+
if (!isSupported) {
|
19
|
+
el.setAttribute(eventName, 'return;');
|
20
|
+
isSupported = typeof el[eventName] == 'function';
|
21
|
+
}
|
22
|
+
el = null;
|
23
|
+
return isSupported;
|
24
|
+
}
|
25
|
+
|
26
|
+
function isForm(element) {
|
27
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM';
|
28
|
+
}
|
29
|
+
|
30
|
+
function isInput(element) {
|
31
|
+
if (Object.isElement(element)) {
|
32
|
+
var name = element.nodeName.toUpperCase();
|
33
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA';
|
34
|
+
}
|
35
|
+
else return false;
|
36
|
+
}
|
37
|
+
|
38
|
+
var submitBubbles = isEventSupported('submit'),
|
39
|
+
changeBubbles = isEventSupported('change');
|
40
|
+
|
41
|
+
if (!submitBubbles || !changeBubbles) {
|
42
|
+
// augment the Event.Handler class to observe custom events when needed
|
43
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
44
|
+
function(init, element, eventName, selector, callback) {
|
45
|
+
init(element, eventName, selector, callback);
|
46
|
+
// is the handler being attached to an element that doesn't support this event?
|
47
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
48
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
49
|
+
// "submit" => "emulated:submit"
|
50
|
+
this.eventName = 'emulated:' + this.eventName;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
);
|
54
|
+
}
|
55
|
+
|
56
|
+
if (!submitBubbles) {
|
57
|
+
// discover forms on the page by observing focus events which always bubble
|
58
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
59
|
+
// special handler for the real "submit" event (one-time operation)
|
60
|
+
if (!form.retrieve('emulated:submit')) {
|
61
|
+
form.on('submit', function(submitEvent) {
|
62
|
+
var emulated = form.fire('emulated:submit', submitEvent, true);
|
63
|
+
// if custom event received preventDefault, cancel the real one too
|
64
|
+
if (emulated.returnValue === false) submitEvent.preventDefault();
|
65
|
+
});
|
66
|
+
form.store('emulated:submit', true);
|
67
|
+
}
|
68
|
+
});
|
69
|
+
}
|
70
|
+
|
71
|
+
if (!changeBubbles) {
|
72
|
+
// discover form inputs on the page
|
73
|
+
document.on('focusin', 'input, select, textarea', function(focusEvent, input) {
|
74
|
+
// special handler for real "change" events
|
75
|
+
if (!input.retrieve('emulated:change')) {
|
76
|
+
input.on('change', function(changeEvent) {
|
77
|
+
input.fire('emulated:change', changeEvent, true);
|
78
|
+
});
|
79
|
+
input.store('emulated:change', true);
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
function handleRemote(element) {
|
85
|
+
var method, url, params;
|
86
|
+
|
87
|
+
var event = element.fire("ajax:before");
|
88
|
+
if (event.stopped) return false;
|
89
|
+
|
90
|
+
if (element.tagName.toLowerCase() === 'form') {
|
91
|
+
method = element.readAttribute('method') || 'post';
|
92
|
+
url = element.readAttribute('action');
|
93
|
+
// serialize the form with respect to the submit button that was pressed
|
94
|
+
params = element.serialize({ submit: element.retrieve('rails:submit-button') });
|
95
|
+
// clear the pressed submit button information
|
96
|
+
element.store('rails:submit-button', null);
|
97
|
+
} else {
|
98
|
+
method = element.readAttribute('data-method') || 'get';
|
99
|
+
url = element.readAttribute('href');
|
100
|
+
params = {};
|
101
|
+
}
|
102
|
+
|
103
|
+
new Ajax.Request(url, {
|
104
|
+
method: method,
|
105
|
+
parameters: params,
|
106
|
+
evalScripts: true,
|
107
|
+
|
108
|
+
onCreate: function(response) { element.fire("ajax:create", response); },
|
109
|
+
onComplete: function(response) { element.fire("ajax:complete", response); },
|
110
|
+
onSuccess: function(response) { element.fire("ajax:success", response); },
|
111
|
+
onFailure: function(response) { element.fire("ajax:failure", response); }
|
112
|
+
});
|
113
|
+
|
114
|
+
element.fire("ajax:after");
|
115
|
+
}
|
116
|
+
|
117
|
+
function insertHiddenField(form, name, value) {
|
118
|
+
form.insert(new Element('input', { type: 'hidden', name: name, value: value }));
|
119
|
+
}
|
120
|
+
|
121
|
+
function handleMethod(element) {
|
122
|
+
var method = element.readAttribute('data-method'),
|
123
|
+
url = element.readAttribute('href'),
|
124
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
125
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
126
|
+
|
127
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
128
|
+
$(element.parentNode).insert(form);
|
129
|
+
|
130
|
+
if (method !== 'post') {
|
131
|
+
insertHiddenField(form, '_method', method);
|
132
|
+
}
|
133
|
+
|
134
|
+
if (csrf_param) {
|
135
|
+
insertHiddenField(form, csrf_param.readAttribute('content'), csrf_token.readAttribute('content'));
|
136
|
+
}
|
137
|
+
|
138
|
+
form.submit();
|
139
|
+
}
|
140
|
+
|
141
|
+
function disableFormElements(form) {
|
142
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
143
|
+
input.store('rails:original-value', input.getValue());
|
144
|
+
input.setValue(input.readAttribute('data-disable-with')).disable();
|
145
|
+
});
|
146
|
+
}
|
147
|
+
|
148
|
+
function enableFormElements(form) {
|
149
|
+
form.select('input[type=submit][data-disable-with]').each(function(input) {
|
150
|
+
input.setValue(input.retrieve('rails:original-value')).enable();
|
151
|
+
});
|
152
|
+
}
|
153
|
+
|
154
|
+
function allowAction(element) {
|
155
|
+
var message = element.readAttribute('data-confirm');
|
156
|
+
return !message || confirm(message);
|
157
|
+
}
|
158
|
+
|
159
|
+
document.on('click', 'a[data-confirm], a[data-remote], a[data-method]', function(event, link) {
|
160
|
+
if (!allowAction(link)) {
|
161
|
+
event.stop();
|
162
|
+
return false;
|
163
|
+
}
|
164
|
+
|
165
|
+
if (link.readAttribute('data-remote')) {
|
166
|
+
handleRemote(link);
|
167
|
+
event.stop();
|
168
|
+
} else if (link.readAttribute('data-method')) {
|
169
|
+
handleMethod(link);
|
170
|
+
event.stop();
|
171
|
+
}
|
172
|
+
});
|
173
|
+
|
174
|
+
document.on("click", "form input[type=submit], form button[type=submit], form button:not([type])", function(event, button) {
|
175
|
+
// register the pressed submit button
|
176
|
+
event.findElement('form').store('rails:submit-button', button.name || false);
|
177
|
+
});
|
178
|
+
|
179
|
+
document.on("submit", function(event) {
|
180
|
+
var form = event.findElement();
|
181
|
+
|
182
|
+
if (!allowAction(form)) {
|
183
|
+
event.stop();
|
184
|
+
return false;
|
185
|
+
}
|
186
|
+
|
187
|
+
if (form.readAttribute('data-remote')) {
|
188
|
+
handleRemote(form);
|
189
|
+
event.stop();
|
190
|
+
} else {
|
191
|
+
disableFormElements(form);
|
192
|
+
}
|
193
|
+
});
|
194
|
+
|
195
|
+
document.on('ajax:create', 'form', function(event, form) {
|
196
|
+
if (form == event.findElement()) disableFormElements(form);
|
197
|
+
});
|
198
|
+
|
199
|
+
document.on('ajax:complete', 'form', function(event, form) {
|
200
|
+
if (form == event.findElement()) enableFormElements(form);
|
201
|
+
});
|
202
|
+
})();
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/spec/factories.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :extreme_profile, class: ExtremeAas::ExtremeProfile do
|
3
|
+
end
|
4
|
+
|
5
|
+
factory :extreme_simple_action, class: ExtremeAas::ExtremeSimpleAction do
|
6
|
+
sequence(:controller_name) {|n| "users#{n}" }
|
7
|
+
sequence(:action_name) {|n| "index#{n}" }
|
8
|
+
end
|
9
|
+
|
10
|
+
factory :extreme_simple_action_helper, class: ExtremeAas::ExtremeSimpleAction do
|
11
|
+
sequence(:helper_name) {|n| "users#{n}"}
|
12
|
+
sequence(:method_name) {|n| "button_#{n}"}
|
13
|
+
end
|
14
|
+
|
15
|
+
factory :extreme_grant, class: ExtremeAas::ExtremeGrant do
|
16
|
+
extreme_profile_id {FactoryGirl.create(:extreme_profile).id}
|
17
|
+
extreme_action_id {FactoryGirl.create(:extreme_simple_action).super_action.id}
|
18
|
+
end
|
19
|
+
|
20
|
+
factory :extreme_grant_for_simple_action, parent: :extreme_grant do
|
21
|
+
end
|
22
|
+
|
23
|
+
factory :extreme_action_group, class: ExtremeAas::ExtremeActionGroup do
|
24
|
+
sequence(:name) {|n| "dropbox#{n}"}
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "ControllerAction" do
|
4
|
+
|
5
|
+
it "should grant permission" do
|
6
|
+
action = FactoryGirl.create(:extreme_simple_action, :controller_name => 'users', :action_name => 'index').super_action
|
7
|
+
grant = FactoryGirl.create(:extreme_grant_for_simple_action, :extreme_action_id => action.id)
|
8
|
+
profile = grant.profile #deleteme
|
9
|
+
|
10
|
+
get 'users'
|
11
|
+
response.should be_success
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should grant permission give_permission user's method" do
|
15
|
+
action = FactoryGirl.create(:extreme_simple_action, :controller_name => 'users', :action_name => 'index').super_action
|
16
|
+
profile = FactoryGirl.create :extreme_profile
|
17
|
+
profile.give_permission action
|
18
|
+
get 'users'
|
19
|
+
response.should be_success
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should deny permission" do
|
23
|
+
action = FactoryGirl.create(:extreme_simple_action, :controller_name => 'users', :action_name => 'index').super_action
|
24
|
+
profile = FactoryGirl.create :extreme_profile
|
25
|
+
get 'users'
|
26
|
+
response.response_code.should == 401
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
ENV["RAILS_ROOT"] = File.expand_path("../dummy", __FILE__)
|
4
|
+
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
require "rails/test_help"
|
7
|
+
require "rspec/rails"
|
8
|
+
|
9
|
+
ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
|
10
|
+
|
11
|
+
ActionMailer::Base.delivery_method = :test
|
12
|
+
ActionMailer::Base.perform_deliveries = true
|
13
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
14
|
+
|
15
|
+
Rails.backtrace_cleaner.remove_silencers!
|
16
|
+
|
17
|
+
# Configure capybara for integration testing
|
18
|
+
require "capybara/rails"
|
19
|
+
Capybara.default_driver = :rack_test
|
20
|
+
Capybara.default_selector = :css
|
21
|
+
|
22
|
+
# Run any available migration
|
23
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
24
|
+
|
25
|
+
# Load support files
|
26
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
# Remove this line if you don't want RSpec's should and should_not
|
30
|
+
# methods or matchers
|
31
|
+
require 'rspec/expectations'
|
32
|
+
require 'factory_girl'
|
33
|
+
include ExtremeAas
|
34
|
+
|
35
|
+
config.include RSpec::Matchers
|
36
|
+
FactoryGirl.find_definitions
|
37
|
+
|
38
|
+
# == Mock Framework
|
39
|
+
config.mock_with :rspec
|
40
|
+
|
41
|
+
config.use_transactional_fixtures = true
|
42
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Action Group" do
|
4
|
+
|
5
|
+
it "should export: read groups of controller actions from yml and write in db" do
|
6
|
+
simple_action_one = FactoryGirl.create(:extreme_simple_action, :controller_name => 'UsersController', :action_name => 'index')
|
7
|
+
simple_action_two = FactoryGirl.create(:extreme_simple_action, :controller_name => 'UsersController', :action_name => 'show')
|
8
|
+
action_group = {"dropbox" => [{"action_name" => "index", "controller_name" => 'UsersController'},{"action_name" => "show", "controller_name" => 'UsersController'}]}
|
9
|
+
File.open("#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml", "w") do |out|
|
10
|
+
YAML.dump action_group, out
|
11
|
+
end
|
12
|
+
|
13
|
+
ExtremeActionGroup.export "#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml"
|
14
|
+
group = ExtremeActionGroup.last
|
15
|
+
group.name.should == 'dropbox'
|
16
|
+
group.actions.include?(simple_action_one.super_action).should be_true
|
17
|
+
group.actions.include?(simple_action_two.super_action).should be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should export: read groups of helper methods from yml and write in db" do
|
21
|
+
simple_action_one = FactoryGirl.create(:extreme_simple_action_helper, :helper_name => 'UsersHelper', :method_name => 'index')
|
22
|
+
simple_action_two = FactoryGirl.create(:extreme_simple_action_helper, :helper_name => 'UsersHelper', :method_name => 'show')
|
23
|
+
action_group = {"dropbox" => [{"method_name" => "index", "helper_name" => 'UsersHelper'},{"method_name" => "show", "helper_name" => 'UsersHelper'}]}
|
24
|
+
File.open("#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml", "w") do |out|
|
25
|
+
YAML.dump action_group, out
|
26
|
+
end
|
27
|
+
|
28
|
+
ExtremeActionGroup.export "#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml"
|
29
|
+
group = ExtremeActionGroup.last
|
30
|
+
group.name.should == 'dropbox'
|
31
|
+
group.actions.include?(simple_action_one.super_action).should be_true
|
32
|
+
group.actions.include?(simple_action_two.super_action).should be_true
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should export: read groups of helper methods and controller actions from yml and write in db" do
|
36
|
+
simple_action_one = FactoryGirl.create(:extreme_simple_action, :controller_name => 'UsersController', :action_name => 'index')
|
37
|
+
simple_action_two = FactoryGirl.create(:extreme_simple_action_helper, :helper_name => 'UsersHelper', :method_name => 'show')
|
38
|
+
action_group = {"dropbox" => [{"action_name" => "index", "controller_name" => 'UsersController'},{"method_name" => "show", "helper_name" => 'UsersHelper'}]}
|
39
|
+
File.open("#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml", "w") do |out|
|
40
|
+
YAML.dump action_group, out
|
41
|
+
end
|
42
|
+
|
43
|
+
ExtremeActionGroup.export "#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml"
|
44
|
+
group = ExtremeActionGroup.last
|
45
|
+
group.name.should == 'dropbox'
|
46
|
+
group.actions.include?(simple_action_one.super_action).should be_true
|
47
|
+
group.actions.include?(simple_action_two.super_action).should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should export: read groups of groups" do
|
51
|
+
simple_action_one = FactoryGirl.create(:extreme_simple_action, :controller_name => 'UsersController', :action_name => 'index')
|
52
|
+
simple_action_two = FactoryGirl.create(:extreme_simple_action_helper, :helper_name => 'UsersHelper', :method_name => 'show')
|
53
|
+
hash = {"group_child" => [{"action_name" => "index", "controller_name" => 'UsersController'}], "group_parent"=>[{"group"=>"group_child"},{"method_name" => "show", "helper_name" => 'UsersHelper'}]}
|
54
|
+
File.open("#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml", "w") do |out|
|
55
|
+
YAML.dump hash, out
|
56
|
+
end
|
57
|
+
|
58
|
+
ExtremeActionGroup.export "#{ENGINE_RAILS_ROOT}/spec/support/extreme_aas_groups.yml"
|
59
|
+
group_parent = ExtremeActionGroup.find_by_name "group_parent"
|
60
|
+
group_child = ExtremeActionGroup.find_by_name "group_child"
|
61
|
+
group_parent.actions.include?(group_child.super_action).should be_true
|
62
|
+
group_parent.actions.include?(simple_action_two.super_action).should be_true
|
63
|
+
p group_parent.actions
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Simple Action for controllers" do
|
4
|
+
|
5
|
+
it "should find a simple action" do
|
6
|
+
simple_action = ExtremeSimpleAction.create :controller_name => 'users', :action_name => 'index'
|
7
|
+
found_simple_action = ExtremeSimpleAction.find_action :action_name => simple_action.action_name, :controller_name => simple_action.controller_name
|
8
|
+
found_simple_action.should_not be_nil
|
9
|
+
#profile.has_permission?(simple_action).should be_true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should grant permission" do
|
13
|
+
grant = FactoryGirl.create(:extreme_grant_for_simple_action)
|
14
|
+
action = grant.action
|
15
|
+
profile = grant.profile
|
16
|
+
action.has_permission?(profile).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not grant permission" do
|
20
|
+
grant = FactoryGirl.create(:extreme_grant_for_simple_action)
|
21
|
+
action = FactoryGirl.create :extreme_simple_action
|
22
|
+
profile = FactoryGirl.create :extreme_profile
|
23
|
+
action.has_permission?(profile).should be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
describe "Simple Action for helpers" do
|
29
|
+
it "should find a simple action" do
|
30
|
+
simple_action = FactoryGirl.create :extreme_simple_action_helper
|
31
|
+
found_simple_action = ExtremeSimpleAction.find_action :helper_name => simple_action.helper_name, :method_name => simple_action.method_name
|
32
|
+
found_simple_action.should_not be_nil
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,235 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extreme_aas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luis Cruz
|
9
|
+
- Martina Simicic
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rails
|
17
|
+
requirement: &2152734380 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.2.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2152734380
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: capybara
|
28
|
+
requirement: &2152733640 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *2152733640
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec-rails
|
39
|
+
requirement: &2152732940 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '2.5'
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *2152732940
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: factory_girl_rails
|
50
|
+
requirement: &2152732400 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *2152732400
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: mysql2
|
61
|
+
requirement: &2152731200 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
type: :development
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: *2152731200
|
70
|
+
description: This gem allows you to specify permissions at controller action or helper
|
71
|
+
methods levels.
|
72
|
+
email:
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rvmrc
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- MIT-LICENSE
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- app/models/extreme_aas/application_controller.rb
|
85
|
+
- app/models/extreme_aas/extreme_action.rb
|
86
|
+
- app/models/extreme_aas/extreme_action_abstract.rb
|
87
|
+
- app/models/extreme_aas/extreme_action_edge.rb
|
88
|
+
- app/models/extreme_aas/extreme_action_group.rb
|
89
|
+
- app/models/extreme_aas/extreme_grant.rb
|
90
|
+
- app/models/extreme_aas/extreme_profile.rb
|
91
|
+
- app/models/extreme_aas/extreme_simple_action.rb
|
92
|
+
- extreme_aas.gemspec
|
93
|
+
- lib/extreme_aas.rb
|
94
|
+
- lib/extreme_aas/engine.rb
|
95
|
+
- lib/extreme_aas/version.rb
|
96
|
+
- lib/generators/extreme_aas/extreme_aas_generator.rb
|
97
|
+
- lib/generators/extreme_aas/templates/migration.rb
|
98
|
+
- lib/tasks/sync.rake
|
99
|
+
- spec/dummy/Gemfile.lock
|
100
|
+
- spec/dummy/Rakefile
|
101
|
+
- spec/dummy/app/assets/javascripts/users.js
|
102
|
+
- spec/dummy/app/assets/stylesheets/scaffold.css
|
103
|
+
- spec/dummy/app/assets/stylesheets/users.css
|
104
|
+
- spec/dummy/app/controllers/application_controller.rb
|
105
|
+
- spec/dummy/app/controllers/users_controller.rb
|
106
|
+
- spec/dummy/app/helpers/application_helper.rb
|
107
|
+
- spec/dummy/app/helpers/users_helper.rb
|
108
|
+
- spec/dummy/app/models/user.rb
|
109
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
110
|
+
- spec/dummy/app/views/users/_form.html.erb
|
111
|
+
- spec/dummy/app/views/users/edit.html.erb
|
112
|
+
- spec/dummy/app/views/users/index.html.erb
|
113
|
+
- spec/dummy/app/views/users/new.html.erb
|
114
|
+
- spec/dummy/app/views/users/show.html.erb
|
115
|
+
- spec/dummy/config.ru
|
116
|
+
- spec/dummy/config/application.rb
|
117
|
+
- spec/dummy/config/boot.rb
|
118
|
+
- spec/dummy/config/database.yml
|
119
|
+
- spec/dummy/config/database_template.yml
|
120
|
+
- spec/dummy/config/environment.rb
|
121
|
+
- spec/dummy/config/environments/development.rb
|
122
|
+
- spec/dummy/config/environments/production.rb
|
123
|
+
- spec/dummy/config/environments/test.rb
|
124
|
+
- spec/dummy/config/extreme_aas_groups.yml
|
125
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
126
|
+
- spec/dummy/config/initializers/inflections.rb
|
127
|
+
- spec/dummy/config/initializers/mime_types.rb
|
128
|
+
- spec/dummy/config/initializers/secret_token.rb
|
129
|
+
- spec/dummy/config/initializers/session_store.rb
|
130
|
+
- spec/dummy/config/locales/en.yml
|
131
|
+
- spec/dummy/config/routes.rb
|
132
|
+
- spec/dummy/db/migrate/20120404105554_create_users.rb
|
133
|
+
- spec/dummy/db/migrate/20120413132357_create_extreme_aas_tables.rb
|
134
|
+
- spec/dummy/db/schema.rb
|
135
|
+
- spec/dummy/public/401.html
|
136
|
+
- spec/dummy/public/404.html
|
137
|
+
- spec/dummy/public/422.html
|
138
|
+
- spec/dummy/public/500.html
|
139
|
+
- spec/dummy/public/favicon.ico
|
140
|
+
- spec/dummy/public/javascripts/application.js
|
141
|
+
- spec/dummy/public/javascripts/controls.js
|
142
|
+
- spec/dummy/public/javascripts/dragdrop.js
|
143
|
+
- spec/dummy/public/javascripts/effects.js
|
144
|
+
- spec/dummy/public/javascripts/prototype.js
|
145
|
+
- spec/dummy/public/javascripts/rails.js
|
146
|
+
- spec/dummy/public/stylesheets/.gitkeep
|
147
|
+
- spec/dummy/script/rails
|
148
|
+
- spec/factories.rb
|
149
|
+
- spec/integration/controller_actions_spec.rb
|
150
|
+
- spec/integration/navigation_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
- spec/support/extreme_aas_groups.yml
|
153
|
+
- spec/unit/action_group_spec.rb
|
154
|
+
- spec/unit/simple_action_spec.rb
|
155
|
+
homepage: https://github.com/kiddosware/extreme_aas
|
156
|
+
licenses: []
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>'
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 1.3.6
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 1.8.11
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Gem for implementing Authentication Authorization System.
|
179
|
+
test_files:
|
180
|
+
- spec/dummy/Gemfile.lock
|
181
|
+
- spec/dummy/Rakefile
|
182
|
+
- spec/dummy/app/assets/javascripts/users.js
|
183
|
+
- spec/dummy/app/assets/stylesheets/scaffold.css
|
184
|
+
- spec/dummy/app/assets/stylesheets/users.css
|
185
|
+
- spec/dummy/app/controllers/application_controller.rb
|
186
|
+
- spec/dummy/app/controllers/users_controller.rb
|
187
|
+
- spec/dummy/app/helpers/application_helper.rb
|
188
|
+
- spec/dummy/app/helpers/users_helper.rb
|
189
|
+
- spec/dummy/app/models/user.rb
|
190
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
191
|
+
- spec/dummy/app/views/users/_form.html.erb
|
192
|
+
- spec/dummy/app/views/users/edit.html.erb
|
193
|
+
- spec/dummy/app/views/users/index.html.erb
|
194
|
+
- spec/dummy/app/views/users/new.html.erb
|
195
|
+
- spec/dummy/app/views/users/show.html.erb
|
196
|
+
- spec/dummy/config.ru
|
197
|
+
- spec/dummy/config/application.rb
|
198
|
+
- spec/dummy/config/boot.rb
|
199
|
+
- spec/dummy/config/database.yml
|
200
|
+
- spec/dummy/config/database_template.yml
|
201
|
+
- spec/dummy/config/environment.rb
|
202
|
+
- spec/dummy/config/environments/development.rb
|
203
|
+
- spec/dummy/config/environments/production.rb
|
204
|
+
- spec/dummy/config/environments/test.rb
|
205
|
+
- spec/dummy/config/extreme_aas_groups.yml
|
206
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
207
|
+
- spec/dummy/config/initializers/inflections.rb
|
208
|
+
- spec/dummy/config/initializers/mime_types.rb
|
209
|
+
- spec/dummy/config/initializers/secret_token.rb
|
210
|
+
- spec/dummy/config/initializers/session_store.rb
|
211
|
+
- spec/dummy/config/locales/en.yml
|
212
|
+
- spec/dummy/config/routes.rb
|
213
|
+
- spec/dummy/db/migrate/20120404105554_create_users.rb
|
214
|
+
- spec/dummy/db/migrate/20120413132357_create_extreme_aas_tables.rb
|
215
|
+
- spec/dummy/db/schema.rb
|
216
|
+
- spec/dummy/public/401.html
|
217
|
+
- spec/dummy/public/404.html
|
218
|
+
- spec/dummy/public/422.html
|
219
|
+
- spec/dummy/public/500.html
|
220
|
+
- spec/dummy/public/favicon.ico
|
221
|
+
- spec/dummy/public/javascripts/application.js
|
222
|
+
- spec/dummy/public/javascripts/controls.js
|
223
|
+
- spec/dummy/public/javascripts/dragdrop.js
|
224
|
+
- spec/dummy/public/javascripts/effects.js
|
225
|
+
- spec/dummy/public/javascripts/prototype.js
|
226
|
+
- spec/dummy/public/javascripts/rails.js
|
227
|
+
- spec/dummy/public/stylesheets/.gitkeep
|
228
|
+
- spec/dummy/script/rails
|
229
|
+
- spec/factories.rb
|
230
|
+
- spec/integration/controller_actions_spec.rb
|
231
|
+
- spec/integration/navigation_spec.rb
|
232
|
+
- spec/spec_helper.rb
|
233
|
+
- spec/support/extreme_aas_groups.yml
|
234
|
+
- spec/unit/action_group_spec.rb
|
235
|
+
- spec/unit/simple_action_spec.rb
|