merit 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +103 -0
- data/README.markdown +17 -2
- data/app/models/badge.rb +27 -19
- data/app/models/merit_action.rb +5 -3
- data/app/models/sash.rb +5 -14
- data/lib/generators/active_record/merit_generator.rb +14 -14
- data/lib/generators/{merit → active_record}/templates/create_badges_sashes.rb +0 -0
- data/lib/generators/{merit → active_record}/templates/create_merit_actions.rb +0 -0
- data/lib/generators/{merit → active_record}/templates/create_sashes.rb +0 -0
- data/lib/generators/merit/install_generator.rb +3 -20
- data/lib/generators/merit/merit_generator.rb +12 -0
- data/lib/generators/merit/templates/merit.rb +10 -1
- data/lib/merit.rb +11 -2
- data/lib/merit/controller_extensions.rb +2 -2
- data/lib/merit/model_additions.rb +18 -17
- data/lib/merit/models/active_record/badges_sash.rb +12 -0
- data/lib/merit/models/active_record/merit_action.rb +2 -0
- data/lib/merit/models/active_record/sash.rb +12 -0
- data/lib/merit/models/mongo_mapper/merit_action.rb +12 -0
- data/lib/merit/models/mongo_mapper/sash.rb +15 -0
- data/lib/merit/rule.rb +2 -2
- data/lib/merit/rules_badge.rb +1 -1
- data/merit.gemspec +16 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +7 -0
- data/test/dummy/app/controllers/comments_controller.rb +90 -0
- data/test/dummy/app/controllers/registrations_controller.rb +15 -0
- data/test/dummy/app/controllers/users_controller.rb +67 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/comment.rb +4 -0
- data/test/dummy/app/models/merit_badge_rules.rb +41 -0
- data/test/dummy/app/models/merit_point_rules.rb +18 -0
- data/test/dummy/app/models/merit_rank_rules.rb +25 -0
- data/test/dummy/app/models/user.rb +9 -0
- data/test/dummy/app/views/comments/_form.html.erb +29 -0
- data/test/dummy/app/views/comments/edit.html.erb +6 -0
- data/test/dummy/app/views/comments/index.html.erb +35 -0
- data/test/dummy/app/views/comments/new.html.erb +5 -0
- data/test/dummy/app/views/comments/show.html.erb +23 -0
- data/test/dummy/app/views/layouts/application.html.haml +18 -0
- data/test/dummy/app/views/users/_form.html.erb +22 -0
- data/test/dummy/app/views/users/edit.html.erb +6 -0
- data/test/dummy/app/views/users/index.html.erb +26 -0
- data/test/dummy/app/views/users/new.html.erb +5 -0
- data/test/dummy/app/views/users/show.html.erb +18 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/badges_data.rb +40 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +9 -0
- data/test/dummy/db/migrate/20110421191249_create_users.rb +12 -0
- data/test/dummy/db/migrate/20110421191250_create_comments.rb +16 -0
- data/test/dummy/db/schema.rb +61 -0
- data/test/dummy/db/seeds.rb +17 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +191 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +132 -0
- data/test/merit_unit_test.rb +22 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +22 -0
- metadata +132 -13
- data/app/models/badges_sash.rb +0 -14
- data/lib/generators/merit/templates/create_badges.rb +0 -19
@@ -0,0 +1,191 @@
|
|
1
|
+
(function() {
|
2
|
+
// Technique from Juriy Zaytsev
|
3
|
+
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
+
function isEventSupported(eventName) {
|
5
|
+
var el = document.createElement('div');
|
6
|
+
eventName = 'on' + eventName;
|
7
|
+
var isSupported = (eventName in el);
|
8
|
+
if (!isSupported) {
|
9
|
+
el.setAttribute(eventName, 'return;');
|
10
|
+
isSupported = typeof el[eventName] == 'function';
|
11
|
+
}
|
12
|
+
el = null;
|
13
|
+
return isSupported;
|
14
|
+
}
|
15
|
+
|
16
|
+
function isForm(element) {
|
17
|
+
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
+
}
|
19
|
+
|
20
|
+
function isInput(element) {
|
21
|
+
if (Object.isElement(element)) {
|
22
|
+
var name = element.nodeName.toUpperCase()
|
23
|
+
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
+
}
|
25
|
+
else return false
|
26
|
+
}
|
27
|
+
|
28
|
+
var submitBubbles = isEventSupported('submit'),
|
29
|
+
changeBubbles = isEventSupported('change')
|
30
|
+
|
31
|
+
if (!submitBubbles || !changeBubbles) {
|
32
|
+
// augment the Event.Handler class to observe custom events when needed
|
33
|
+
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
+
function(init, element, eventName, selector, callback) {
|
35
|
+
init(element, eventName, selector, callback)
|
36
|
+
// is the handler being attached to an element that doesn't support this event?
|
37
|
+
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
+
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
+
// "submit" => "emulated:submit"
|
40
|
+
this.eventName = 'emulated:' + this.eventName
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
44
|
+
}
|
45
|
+
|
46
|
+
if (!submitBubbles) {
|
47
|
+
// discover forms on the page by observing focus events which always bubble
|
48
|
+
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
+
// special handler for the real "submit" event (one-time operation)
|
50
|
+
if (!form.retrieve('emulated:submit')) {
|
51
|
+
form.on('submit', function(submitEvent) {
|
52
|
+
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
+
// if custom event received preventDefault, cancel the real one too
|
54
|
+
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
+
})
|
56
|
+
form.store('emulated:submit', true)
|
57
|
+
}
|
58
|
+
})
|
59
|
+
}
|
60
|
+
|
61
|
+
if (!changeBubbles) {
|
62
|
+
// discover form inputs on the page
|
63
|
+
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
+
// special handler for real "change" events
|
65
|
+
if (!input.retrieve('emulated:change')) {
|
66
|
+
input.on('change', function(changeEvent) {
|
67
|
+
input.fire('emulated:change', changeEvent, true)
|
68
|
+
})
|
69
|
+
input.store('emulated:change', true)
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
|
74
|
+
function handleRemote(element) {
|
75
|
+
var method, url, params;
|
76
|
+
|
77
|
+
var event = element.fire("ajax:before");
|
78
|
+
if (event.stopped) return false;
|
79
|
+
|
80
|
+
if (element.tagName.toLowerCase() === 'form') {
|
81
|
+
method = element.readAttribute('method') || 'post';
|
82
|
+
url = element.readAttribute('action');
|
83
|
+
params = element.serialize();
|
84
|
+
} else {
|
85
|
+
method = element.readAttribute('data-method') || 'get';
|
86
|
+
url = element.readAttribute('href');
|
87
|
+
params = {};
|
88
|
+
}
|
89
|
+
|
90
|
+
new Ajax.Request(url, {
|
91
|
+
method: method,
|
92
|
+
parameters: params,
|
93
|
+
evalScripts: true,
|
94
|
+
|
95
|
+
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
+
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
+
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
+
});
|
99
|
+
|
100
|
+
element.fire("ajax:after");
|
101
|
+
}
|
102
|
+
|
103
|
+
function handleMethod(element) {
|
104
|
+
var method = element.readAttribute('data-method'),
|
105
|
+
url = element.readAttribute('href'),
|
106
|
+
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
+
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
+
|
109
|
+
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
+
element.parentNode.insert(form);
|
111
|
+
|
112
|
+
if (method !== 'post') {
|
113
|
+
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
+
form.insert(field);
|
115
|
+
}
|
116
|
+
|
117
|
+
if (csrf_param) {
|
118
|
+
var param = csrf_param.readAttribute('content'),
|
119
|
+
token = csrf_token.readAttribute('content'),
|
120
|
+
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
+
form.insert(field);
|
122
|
+
}
|
123
|
+
|
124
|
+
form.submit();
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
+
var message = element.readAttribute('data-confirm');
|
130
|
+
if (!confirm(message)) event.stop();
|
131
|
+
});
|
132
|
+
|
133
|
+
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
+
if (event.stopped) return;
|
135
|
+
handleRemote(element);
|
136
|
+
event.stop();
|
137
|
+
});
|
138
|
+
|
139
|
+
document.on("click", "a[data-method]", function(event, element) {
|
140
|
+
if (event.stopped) return;
|
141
|
+
handleMethod(element);
|
142
|
+
event.stop();
|
143
|
+
});
|
144
|
+
|
145
|
+
document.on("submit", function(event) {
|
146
|
+
var element = event.findElement(),
|
147
|
+
message = element.readAttribute('data-confirm');
|
148
|
+
if (message && !confirm(message)) {
|
149
|
+
event.stop();
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
|
153
|
+
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
+
inputs.each(function(input) {
|
155
|
+
input.disabled = true;
|
156
|
+
input.writeAttribute('data-original-value', input.value);
|
157
|
+
input.value = input.readAttribute('data-disable-with');
|
158
|
+
});
|
159
|
+
|
160
|
+
var element = event.findElement("form[data-remote]");
|
161
|
+
if (element) {
|
162
|
+
handleRemote(element);
|
163
|
+
event.stop();
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
document.on("ajax:after", "form", function(event, element) {
|
168
|
+
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
+
inputs.each(function(input) {
|
170
|
+
input.value = input.readAttribute('data-original-value');
|
171
|
+
input.removeAttribute('data-original-value');
|
172
|
+
input.disabled = false;
|
173
|
+
});
|
174
|
+
});
|
175
|
+
|
176
|
+
Ajax.Responders.register({
|
177
|
+
onCreate: function(request) {
|
178
|
+
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
|
179
|
+
|
180
|
+
if (csrf_meta_tag) {
|
181
|
+
var header = 'X-CSRF-Token',
|
182
|
+
token = csrf_meta_tag.readAttribute('content');
|
183
|
+
|
184
|
+
if (!request.options.requestHeaders) {
|
185
|
+
request.options.requestHeaders = {};
|
186
|
+
}
|
187
|
+
request.options.requestHeaders[header] = token;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
});
|
191
|
+
})();
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -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'
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NavigationTest < ActiveSupport::IntegrationCase
|
4
|
+
setup do
|
5
|
+
User.create(:name => 'test-user')
|
6
|
+
end
|
7
|
+
|
8
|
+
test 'user workflow should grant some badges at some times' do
|
9
|
+
user = User.first
|
10
|
+
assert user.badges.empty?
|
11
|
+
|
12
|
+
# Commented 9 times, no badges yet
|
13
|
+
(1..9).each do |i|
|
14
|
+
Comment.create(
|
15
|
+
:name => "Title #{i}",
|
16
|
+
:comment => "Comment #{i}",
|
17
|
+
:user_id => user.id,
|
18
|
+
:votes => 8
|
19
|
+
)
|
20
|
+
end
|
21
|
+
assert user.badges.empty?, 'Should not have badges'
|
22
|
+
|
23
|
+
# Make tenth comment, assert 10-commenter badge granted
|
24
|
+
visit '/comments/new'
|
25
|
+
fill_in 'Name', :with => 'Hi!'
|
26
|
+
fill_in 'Comment', :with => 'Hi bro!'
|
27
|
+
fill_in 'User', :with => user.id
|
28
|
+
click_button('Create Comment')
|
29
|
+
|
30
|
+
user = User.where(:name => 'test-user').first
|
31
|
+
assert_equal [Badge.by_name('commenter').by_level(10).first], user.badges
|
32
|
+
|
33
|
+
# Vote (to 5) a user's comment, assert relevant-commenter badge granted
|
34
|
+
relevant_comment = user.comments.where(:votes => 8).first
|
35
|
+
visit '/comments'
|
36
|
+
within("tr#c_#{relevant_comment.id}") do
|
37
|
+
click_link '2'
|
38
|
+
end
|
39
|
+
|
40
|
+
relevant_badge = Badge.by_name('relevant-commenter').first
|
41
|
+
user_badges = User.where(:name => 'test-user').first.badges
|
42
|
+
assert user_badges.include?(relevant_badge), "User badges: #{user.badges.collect(&:name).inspect} should contain relevant-commenter badge."
|
43
|
+
|
44
|
+
# Edit user's name by long name
|
45
|
+
# tests ruby code in grant_on is being executed, and gives badge
|
46
|
+
user = User.where(:name => 'test-user').first
|
47
|
+
user_badges = user.badges
|
48
|
+
|
49
|
+
visit "/users/#{user.id}/edit"
|
50
|
+
fill_in 'Name', :with => 'long_name!'
|
51
|
+
click_button('Update User')
|
52
|
+
|
53
|
+
user = User.where(:name => 'long_name!').first
|
54
|
+
autobiographer_badge = Badge.by_name('autobiographer').first
|
55
|
+
assert user.badges.include?(autobiographer_badge), "User badges: #{user.badges.collect(&:name).inspect} should contain autobiographer badge."
|
56
|
+
|
57
|
+
# Edit user's name by short name
|
58
|
+
# tests ruby code in grant_on is being executed, and removes badge
|
59
|
+
visit "/users/#{user.id}/edit"
|
60
|
+
fill_in 'Name', :with => 'abc'
|
61
|
+
click_button('Update User')
|
62
|
+
|
63
|
+
user = User.where(:name => 'abc').first
|
64
|
+
assert !user.badges.include?(autobiographer_badge), "User badges: #{user.badges.collect(&:name).inspect} should remove autobiographer badge."
|
65
|
+
end
|
66
|
+
|
67
|
+
test 'user workflow should add up points at some times' do
|
68
|
+
user = User.first
|
69
|
+
assert_equal 0, user.points, 'User should start with 0 points'
|
70
|
+
|
71
|
+
visit "/users/#{user.id}/edit"
|
72
|
+
fill_in 'Name', :with => 'a'
|
73
|
+
click_button('Update User')
|
74
|
+
|
75
|
+
user = User.where(:name => 'a').first
|
76
|
+
assert_equal 20, user.points, 'Updating info should grant 20 points'
|
77
|
+
|
78
|
+
visit '/comments/new'
|
79
|
+
click_button('Create Comment')
|
80
|
+
|
81
|
+
user = User.where(:name => 'a').first
|
82
|
+
assert_equal 20, user.points, 'Empty comment should grant no points'
|
83
|
+
|
84
|
+
visit '/comments/new'
|
85
|
+
fill_in 'Name', :with => 'Hi!'
|
86
|
+
fill_in 'Comment', :with => 'Hi bro!'
|
87
|
+
fill_in 'User', :with => user.id
|
88
|
+
click_button('Create Comment')
|
89
|
+
|
90
|
+
user = User.where(:name => 'a').first
|
91
|
+
assert_equal 40, user.points, 'Commenting should grant 20 points'
|
92
|
+
|
93
|
+
visit "/comments/1/vote/4"
|
94
|
+
user = User.first
|
95
|
+
assert_equal 45, user.points, 'Voting comments should grant 5 points'
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'user workflow should grant stars at some times' do
|
99
|
+
user = User.first
|
100
|
+
assert user.badges.empty?
|
101
|
+
|
102
|
+
# Edit user's name by 2 chars name
|
103
|
+
visit "/users/#{user.id}/edit"
|
104
|
+
fill_in 'Name', :with => 'ab'
|
105
|
+
click_button('Update User')
|
106
|
+
|
107
|
+
user = User.where(:name => 'ab').first
|
108
|
+
stars2 = Badge.by_name(:stars).by_level(2).first
|
109
|
+
MeritRankRules.new.check_rank_rules
|
110
|
+
assert_equal user.badges, [stars2], "User badges: #{user.badges.collect(&:name).inspect} should contain only 2-stars badge."
|
111
|
+
|
112
|
+
# Edit user's name by short name. Doesn't go back to previous rank.
|
113
|
+
visit "/users/#{user.id}/edit"
|
114
|
+
fill_in 'Name', :with => 'a'
|
115
|
+
click_button('Update User')
|
116
|
+
|
117
|
+
user = User.where(:name => 'a').first
|
118
|
+
MeritRankRules.new.check_rank_rules
|
119
|
+
assert_equal user.badges, [stars2], "User badges: #{user.badges.collect(&:name).inspect} should contain only 2-stars badge."
|
120
|
+
|
121
|
+
# Edit user's name by 5 chars name
|
122
|
+
visit "/users/#{user.id}/edit"
|
123
|
+
fill_in 'Name', :with => 'abcde'
|
124
|
+
click_button('Update User')
|
125
|
+
|
126
|
+
user = User.where(:name => 'abcde').first
|
127
|
+
stars5 = Badge.by_name(:stars).by_level(5).first
|
128
|
+
assert_equal Badge.find_by_id(user.sash.badge_ids).by_name(:stars).count, 1, "Should not contain more than 2 stars ranking."
|
129
|
+
MeritRankRules.new.check_rank_rules
|
130
|
+
assert user.badges.include?(stars5), "User badges: #{user.badges.collect(&:name).inspect} should contain 5-stars badge."
|
131
|
+
end
|
132
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MeritUnitTest < ActiveSupport::TestCase
|
4
|
+
test "Hash#conditions_apply? tests if object responds what's expected" do
|
5
|
+
hash = { :first => { :odd? => true }, :count => 2 }
|
6
|
+
assert hash.conditions_apply? [1,3]
|
7
|
+
assert not(hash.conditions_apply? [1,2,3])
|
8
|
+
assert not(hash.conditions_apply? [2,3])
|
9
|
+
end
|
10
|
+
|
11
|
+
test "Rule applies?" do
|
12
|
+
rule = Merit::Rule.new
|
13
|
+
assert rule.applies?, 'empty conditions should make rule apply'
|
14
|
+
|
15
|
+
str = "string"
|
16
|
+
rule.block = lambda{|obj| obj.length < 4 }
|
17
|
+
assert !rule.applies?(str), 'block should make rule fail'
|
18
|
+
|
19
|
+
rule.block = lambda{|obj| obj.length >= 4 }
|
20
|
+
assert rule.applies?(str), 'block should make rule apply'
|
21
|
+
end
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Configure Rails Envinronment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
ActionMailer::Base.delivery_method = :test
|
8
|
+
ActionMailer::Base.perform_deliveries = true
|
9
|
+
ActionMailer::Base.default_url_options[:host] = "test.com"
|
10
|
+
|
11
|
+
Rails.backtrace_cleaner.remove_silencers!
|
12
|
+
|
13
|
+
# Configure capybara for integration testing
|
14
|
+
require "capybara/rails"
|
15
|
+
Capybara.default_driver = :rack_test
|
16
|
+
Capybara.default_selector = :css
|
17
|
+
|
18
|
+
# Run any available migration
|
19
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
20
|
+
|
21
|
+
# Load support files
|
22
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,43 +9,162 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ambry
|
16
|
+
requirement: &70301339044400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70301339044400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
requirement: &70301339043920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70301339043920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sqlite3
|
38
|
+
requirement: &70301339043500 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70301339043500
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: haml
|
49
|
+
requirement: &70301339043080 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70301339043080
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: capybara
|
60
|
+
requirement: &70301339042640 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70301339042640
|
14
69
|
description: General reputation Rails engine.
|
15
70
|
email: tutecosta@gmail.com
|
16
71
|
executables: []
|
17
72
|
extensions: []
|
18
73
|
extra_rdoc_files: []
|
19
74
|
files:
|
75
|
+
- Gemfile
|
76
|
+
- Gemfile.lock
|
77
|
+
- MIT-LICENSE
|
78
|
+
- README.markdown
|
79
|
+
- Rakefile
|
20
80
|
- app/models/badge.rb
|
21
|
-
- app/models/badges_sash.rb
|
22
81
|
- app/models/merit_action.rb
|
23
82
|
- app/models/sash.rb
|
24
83
|
- lib/generators/active_record/merit_generator.rb
|
25
84
|
- lib/generators/active_record/templates/add_fields_to_model.rb
|
85
|
+
- lib/generators/active_record/templates/create_badges_sashes.rb
|
86
|
+
- lib/generators/active_record/templates/create_merit_actions.rb
|
87
|
+
- lib/generators/active_record/templates/create_sashes.rb
|
26
88
|
- lib/generators/merit/install_generator.rb
|
27
89
|
- lib/generators/merit/merit_generator.rb
|
28
|
-
- lib/generators/merit/templates/create_badges.rb
|
29
|
-
- lib/generators/merit/templates/create_badges_sashes.rb
|
30
|
-
- lib/generators/merit/templates/create_merit_actions.rb
|
31
|
-
- lib/generators/merit/templates/create_sashes.rb
|
32
90
|
- lib/generators/merit/templates/merit.rb
|
33
91
|
- lib/generators/merit/templates/merit_badge_rules.rb
|
34
92
|
- lib/generators/merit/templates/merit_point_rules.rb
|
35
93
|
- lib/generators/merit/templates/merit_rank_rules.rb
|
94
|
+
- lib/merit.rb
|
36
95
|
- lib/merit/controller_extensions.rb
|
37
96
|
- lib/merit/core_extensions.rb
|
38
97
|
- lib/merit/model_additions.rb
|
98
|
+
- lib/merit/models/active_record/badges_sash.rb
|
99
|
+
- lib/merit/models/active_record/merit_action.rb
|
100
|
+
- lib/merit/models/active_record/sash.rb
|
101
|
+
- lib/merit/models/mongo_mapper/merit_action.rb
|
102
|
+
- lib/merit/models/mongo_mapper/sash.rb
|
39
103
|
- lib/merit/railtie.rb
|
40
104
|
- lib/merit/rule.rb
|
41
105
|
- lib/merit/rules_badge.rb
|
42
106
|
- lib/merit/rules_points.rb
|
43
107
|
- lib/merit/rules_rank.rb
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
108
|
+
- merit.gemspec
|
109
|
+
- test/dummy/Rakefile
|
110
|
+
- test/dummy/app/controllers/application_controller.rb
|
111
|
+
- test/dummy/app/controllers/comments_controller.rb
|
112
|
+
- test/dummy/app/controllers/registrations_controller.rb
|
113
|
+
- test/dummy/app/controllers/users_controller.rb
|
114
|
+
- test/dummy/app/helpers/application_helper.rb
|
115
|
+
- test/dummy/app/models/comment.rb
|
116
|
+
- test/dummy/app/models/merit_badge_rules.rb
|
117
|
+
- test/dummy/app/models/merit_point_rules.rb
|
118
|
+
- test/dummy/app/models/merit_rank_rules.rb
|
119
|
+
- test/dummy/app/models/user.rb
|
120
|
+
- test/dummy/app/views/comments/_form.html.erb
|
121
|
+
- test/dummy/app/views/comments/edit.html.erb
|
122
|
+
- test/dummy/app/views/comments/index.html.erb
|
123
|
+
- test/dummy/app/views/comments/new.html.erb
|
124
|
+
- test/dummy/app/views/comments/show.html.erb
|
125
|
+
- test/dummy/app/views/layouts/application.html.haml
|
126
|
+
- test/dummy/app/views/users/_form.html.erb
|
127
|
+
- test/dummy/app/views/users/edit.html.erb
|
128
|
+
- test/dummy/app/views/users/index.html.erb
|
129
|
+
- test/dummy/app/views/users/new.html.erb
|
130
|
+
- test/dummy/app/views/users/show.html.erb
|
131
|
+
- test/dummy/config.ru
|
132
|
+
- test/dummy/config/application.rb
|
133
|
+
- test/dummy/config/boot.rb
|
134
|
+
- test/dummy/config/database.yml
|
135
|
+
- test/dummy/config/environment.rb
|
136
|
+
- test/dummy/config/environments/development.rb
|
137
|
+
- test/dummy/config/environments/production.rb
|
138
|
+
- test/dummy/config/environments/test.rb
|
139
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
140
|
+
- test/dummy/config/initializers/badges_data.rb
|
141
|
+
- test/dummy/config/initializers/inflections.rb
|
142
|
+
- test/dummy/config/initializers/mime_types.rb
|
143
|
+
- test/dummy/config/initializers/secret_token.rb
|
144
|
+
- test/dummy/config/initializers/session_store.rb
|
145
|
+
- test/dummy/config/locales/en.yml
|
146
|
+
- test/dummy/config/routes.rb
|
147
|
+
- test/dummy/db/migrate/20110421191249_create_users.rb
|
148
|
+
- test/dummy/db/migrate/20110421191250_create_comments.rb
|
149
|
+
- test/dummy/db/schema.rb
|
150
|
+
- test/dummy/db/seeds.rb
|
151
|
+
- test/dummy/public/404.html
|
152
|
+
- test/dummy/public/422.html
|
153
|
+
- test/dummy/public/500.html
|
154
|
+
- test/dummy/public/favicon.ico
|
155
|
+
- test/dummy/public/javascripts/application.js
|
156
|
+
- test/dummy/public/javascripts/controls.js
|
157
|
+
- test/dummy/public/javascripts/dragdrop.js
|
158
|
+
- test/dummy/public/javascripts/effects.js
|
159
|
+
- test/dummy/public/javascripts/prototype.js
|
160
|
+
- test/dummy/public/javascripts/rails.js
|
161
|
+
- test/dummy/public/stylesheets/.gitkeep
|
162
|
+
- test/dummy/public/stylesheets/scaffold.css
|
163
|
+
- test/dummy/script/rails
|
164
|
+
- test/integration/navigation_test.rb
|
165
|
+
- test/merit_unit_test.rb
|
166
|
+
- test/support/integration_case.rb
|
167
|
+
- test/test_helper.rb
|
49
168
|
homepage:
|
50
169
|
licenses: []
|
51
170
|
post_install_message:
|