adhonorem 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +6 -0
- data/Rakefile +30 -0
- data/app/assets/javascripts/adhonorem/application.js +13 -0
- data/app/assets/stylesheets/adhonorem/application.css +15 -0
- data/app/controllers/adhonorem/application_controller.rb +5 -0
- data/app/views/layouts/adhonorem/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/lib/adhonorem/engine.rb +5 -0
- data/lib/adhonorem/exceptions.rb +6 -0
- data/lib/adhonorem/generators/adhonorem_generator.rb +21 -0
- data/lib/adhonorem/generators/templates/achievement_migration.rb +14 -0
- data/lib/adhonorem/generators/templates/initializer.rb +3 -0
- data/lib/adhonorem/generators/templates/progress_migration.rb +11 -0
- data/lib/adhonorem/models/achievement.rb +10 -0
- data/lib/adhonorem/models/badge.rb +240 -0
- data/lib/adhonorem/models/configuration.rb +10 -0
- data/lib/adhonorem/models/objective.rb +14 -0
- data/lib/adhonorem/models/progress.rb +48 -0
- data/lib/adhonorem/railtie.rb +12 -0
- data/lib/adhonorem/version.rb +3 -0
- data/lib/adhonorem.rb +32 -0
- data/lib/tasks/adhonorem_tasks.rake +4 -0
- data/spec/adhonorem_spec.rb +5 -0
- data/spec/helpers/badge_instantiator.rb +14 -0
- data/spec/helpers/migration_has_been_run.rb +28 -0
- data/spec/models/badge_spec.rb +63 -0
- data/spec/models/badge_trigger_spec.rb +53 -0
- data/spec/models/meta_badge_spec.rb +44 -0
- data/spec/rails_helper.rb +15 -0
- data/spec/spec_helper.rb +23 -0
- data/spec/test_app/app/controllers/application_controller.rb +5 -0
- data/spec/test_app/app/helpers/application_helper.rb +2 -0
- data/spec/test_app/app/models/badges/conditionnal_badge.rb +20 -0
- data/spec/test_app/app/models/badges/legacy_badge.rb +20 -0
- data/spec/test_app/app/models/badges/meta_badge.rb +19 -0
- data/spec/test_app/app/models/badges/meta_children/sub_badge_one.rb +20 -0
- data/spec/test_app/app/models/badges/meta_children/sub_badge_two.rb +20 -0
- data/spec/test_app/app/models/badges/normal_badge.rb +20 -0
- data/spec/test_app/app/models/badges/parametered_badge.rb +33 -0
- data/spec/test_app/app/models/badges/two_objectives_badge.rb +25 -0
- data/spec/test_app/app/models/user.rb +2 -0
- data/spec/test_app/config/application.rb +16 -0
- data/spec/test_app/config/boot.rb +5 -0
- data/spec/test_app/config/environment.rb +5 -0
- data/spec/test_app/config/environments/development.rb +20 -0
- data/spec/test_app/config/environments/production.rb +25 -0
- data/spec/test_app/config/environments/test.rb +21 -0
- data/spec/test_app/config/initializers/adhonorem.rb +3 -0
- data/spec/test_app/config/initializers/assets.rb +1 -0
- data/spec/test_app/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/test_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/test_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/test_app/config/initializers/inflections.rb +16 -0
- data/spec/test_app/config/initializers/mime_types.rb +4 -0
- data/spec/test_app/config/initializers/session_store.rb +3 -0
- data/spec/test_app/config/initializers/wrap_parameters.rb +3 -0
- data/spec/test_app/config/routes.rb +3 -0
- data/spec/test_app/db/migrate/20170103065319_create_users.rb +10 -0
- data/spec/test_app/db/migrate/20170103065400_create_adhonorem_progress.rb +10 -0
- data/spec/test_app/db/migrate/20170103065401_create_adhonorem_achievement.rb +12 -0
- data/spec/test_app/db/schema.rb +39 -0
- metadata +271 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_helper'
|
3
|
+
require_relative '../helpers/badge_instantiator'
|
4
|
+
|
5
|
+
RSpec.describe AdHonorem::Badge do
|
6
|
+
it 'inherits StaticRecord::Base' do
|
7
|
+
expect(AdHonorem::Badge.where(name: 'Normal badge').first).to be_a(NormalBadge)
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'without user context' do
|
11
|
+
it 'requires a context User to be set' do
|
12
|
+
badge = AdHonorem::Badge.find('normal_badge')
|
13
|
+
expect { badge.progress }.to raise_error(AdHonorem::NoContext)
|
14
|
+
expect { badge.complete? }.to raise_error(AdHonorem::NoContext)
|
15
|
+
expect { badge.trigger(:visit_paris) }.to raise_error(AdHonorem::NoContext)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with user context' do
|
20
|
+
before(:each) do
|
21
|
+
instantiate_badges
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'works with user set' do
|
25
|
+
expect { @normal_badge.progress }.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'allows to check badge completion' do
|
29
|
+
expect(@normal_badge.complete?).to be false
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'allows to check specific objective completion' do
|
33
|
+
@two_objectives_badge.trigger(:use_longbow)
|
34
|
+
expect(@two_objectives_badge.complete?(:use_longbow)).to be true
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'allows to check specific objective completion' do
|
38
|
+
@two_objectives_badge.trigger(:use_longbow)
|
39
|
+
expect(@two_objectives_badge.complete?(:use_longbow)).to be true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when dispatching an event' do
|
44
|
+
it 'triggers checkers that hooked to dispatched event' do
|
45
|
+
user = User.create(name: 'Dispatch')
|
46
|
+
data = { weapon_used: 'bow' }
|
47
|
+
badge = AdHonorem::Badge.find('parametered_badge').set_context(user)
|
48
|
+
|
49
|
+
res = AdHonorem::Badge.dispatch(user, :mastered_a_weapon, data: data)
|
50
|
+
expect(badge.complete?(:master_bow)).to be true
|
51
|
+
expect(badge.complete?(:master_sword)).to be false
|
52
|
+
expect(badge.complete?).to be false
|
53
|
+
expect(res[:completed_step].include?('ParameteredBadge#master_bow'))
|
54
|
+
expect(res[:failed_check].include?('ParameteredBadge#master_sword'))
|
55
|
+
|
56
|
+
res = AdHonorem::Badge.dispatch(user, :mastered_a_weapon, data: data.merge(weapon_used: 'sword'))
|
57
|
+
expect(badge.complete?(:master_sword)).to be true
|
58
|
+
expect(badge.complete?).to be true
|
59
|
+
expect(res[:completed_badge].include?('ParameteredBadge#master_sword'))
|
60
|
+
expect(res[:already_done].include?('ParameteredBadge#master_bow'))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_helper'
|
3
|
+
require_relative '../helpers/badge_instantiator'
|
4
|
+
|
5
|
+
RSpec.describe AdHonorem::Badge do
|
6
|
+
before(:each) do
|
7
|
+
instantiate_badges
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when triggering a badge step-checker' do
|
11
|
+
it 'returns :triggered when a step-checker returns true but it\'s not fulfilled yet' do
|
12
|
+
expect(@two_objectives_badge.trigger(:use_sword)).to eql(:triggered)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns :failed_check when a step-checker returns false' do
|
16
|
+
expect(@conditionnal_badge.trigger(:whoami)).to eql(:failed_check)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can succeed when conditions match' do
|
20
|
+
darth_vader = User.create(name: 'Darth Vader')
|
21
|
+
@conditionnal_badge.set_context(darth_vader)
|
22
|
+
expect(@conditionnal_badge.trigger(:whoami)).to eql(:completed_badge)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns :completed_step when all conditions for an objective are fulfilled' do
|
26
|
+
expect(@two_objectives_badge.trigger(:use_longbow)).to eql(:completed_step)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns :completed_badge when all conditions for all objectives are fulfilled' do
|
30
|
+
expect(@normal_badge.trigger(:visit_paris)).to eql(:completed_badge)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns :already_done when a badge is alreay unlocked' do
|
34
|
+
expect(@normal_badge.trigger(:visit_paris)).to eql(:completed_badge)
|
35
|
+
expect(@normal_badge.trigger(:visit_paris)).to eql(:already_done)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'returns :legacy_badge when a badge is legacy' do
|
39
|
+
expect(@legacy_badge.trigger(:try_me)).to eql(:legacy_badge)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'allows to trigger an objective several times in a row' do
|
43
|
+
expect(@two_objectives_badge.trigger(:use_sword, {amount: 5})).to eql(:completed_step)
|
44
|
+
expect(@two_objectives_badge.complete?(:use_sword)).to be true
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'allows to pass any data to the checkers' do
|
48
|
+
data = { weapon_used: 'bow' }
|
49
|
+
expect(@parametered_badge.trigger(:master_sword, data: data)).to eql(:failed_check)
|
50
|
+
expect(@parametered_badge.trigger(:master_bow, data: data)).to eql(:completed_step)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rails_helper'
|
3
|
+
|
4
|
+
RSpec.describe AdHonorem::Badge do
|
5
|
+
before(:each) do
|
6
|
+
name = (0...50).map { ('a'..'z').to_a[rand(26)] }.join
|
7
|
+
@user = User.create(name: name)
|
8
|
+
@meta_badge = AdHonorem::Badge.find('meta_badge').set_context(@user)
|
9
|
+
@sub_one = AdHonorem::Badge.find('sub_badge_one').set_context(@user)
|
10
|
+
@sub_two = AdHonorem::Badge.find('sub_badge_two').set_context(@user)
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns next locked badge' do
|
14
|
+
expect(@meta_badge.send(:next_sub_badge).class).to eql(SubBadgeOne)
|
15
|
+
@user.update(level: 10)
|
16
|
+
@meta_badge.trigger(:level_up)
|
17
|
+
expect(@meta_badge.send(:next_sub_badge).class).to eql(SubBadgeTwo)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'delegates objective checks to all locked badge' do
|
21
|
+
@user.update(level: 10)
|
22
|
+
@meta_badge.trigger(:level_up)
|
23
|
+
expect(@sub_one.complete?).to be true
|
24
|
+
expect(@sub_two.complete?).to be false
|
25
|
+
expect(@meta_badge.complete?).to be false
|
26
|
+
|
27
|
+
@user.update(level: 15)
|
28
|
+
@meta_badge.trigger(:level_up)
|
29
|
+
expect(@sub_two.complete?).to be false
|
30
|
+
expect(@meta_badge.complete?).to be false
|
31
|
+
|
32
|
+
@user.update(level: 20)
|
33
|
+
@meta_badge.trigger(:level_up)
|
34
|
+
expect(@sub_two.complete?).to be true
|
35
|
+
expect(@meta_badge.complete?).to be true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'works with event hooking' do
|
39
|
+
@user.update(level: 10)
|
40
|
+
expect(@sub_one.complete?).to be false
|
41
|
+
res = AdHonorem::Badge.dispatch(@user, :level_up)
|
42
|
+
expect(@sub_one.complete?).to be true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
require File.expand_path('../test_app/config/environment', __FILE__)
|
3
|
+
|
4
|
+
abort('Running in production mode!') if Rails.env.production?
|
5
|
+
require 'spec_helper'
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
ActiveRecord::Migration.maintain_test_schema!
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
12
|
+
config.use_transactional_fixtures = true
|
13
|
+
config.infer_spec_type_from_file_location!
|
14
|
+
config.filter_rails_from_backtrace!
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter '/spec/'
|
5
|
+
end
|
6
|
+
|
7
|
+
config.expect_with :rspec do |expectations|
|
8
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
9
|
+
end
|
10
|
+
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
16
|
+
|
17
|
+
config.filter_run_when_matching :focus
|
18
|
+
config.disable_monkey_patching!
|
19
|
+
|
20
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
21
|
+
|
22
|
+
config.order = :random
|
23
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class ConditionnalBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'conditionnal_badge'
|
3
|
+
attribute :name, 'Conditionnal badge'
|
4
|
+
attribute :description, 'This is a conditionnal badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'conditionnal.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'conditionnal.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:whoami, 'I am your father', 'You must be called Darth Vader to finish me')
|
15
|
+
end
|
16
|
+
|
17
|
+
def whoami(user, params)
|
18
|
+
user.name == 'Darth Vader'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class LegacyBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'legacy_badge'
|
3
|
+
attribute :name, 'Legacy badge'
|
4
|
+
attribute :description, 'This is a legacy badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'legacy.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'legacy.png')
|
9
|
+
attribute :legacy, true
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:try_me, 'Alpha tester', 'Granted to heroes who tested the alpha')
|
15
|
+
end
|
16
|
+
|
17
|
+
def try_me(user, params)
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class MetaBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'meta_badge'
|
3
|
+
attribute :name, 'Meta badge'
|
4
|
+
attribute :description, 'This is a meta badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'meta.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'meta.png')
|
9
|
+
attribute :legacy, true
|
10
|
+
|
11
|
+
hook :level_up, to: :level_up
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
|
16
|
+
add_sub_badge(:sub_badge_one)
|
17
|
+
add_sub_badge(:sub_badge_two)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class SubBadgeOne < AdHonorem::Badge
|
2
|
+
attribute :slug, 'sub_badge_one'
|
3
|
+
attribute :name, 'Sub badge one'
|
4
|
+
attribute :description, 'This is the first sub badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'sub_badge_one.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'sub_badge_one.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:level_up, 'Ding', 'Reach level 10')
|
15
|
+
end
|
16
|
+
|
17
|
+
def level_up(user, params)
|
18
|
+
user.level >= 10
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class SubBadgeTwo < AdHonorem::Badge
|
2
|
+
attribute :slug, 'sub_badge_two'
|
3
|
+
attribute :name, 'Sub badge two'
|
4
|
+
attribute :description, 'This is the second sub badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'sub_badge_two.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'sub_badge_two.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:level_up, 'Ding!', 'Reach level 20')
|
15
|
+
end
|
16
|
+
|
17
|
+
def level_up(user, params)
|
18
|
+
user.level >= 20
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class NormalBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'normal_badge'
|
3
|
+
attribute :name, 'Normal badge'
|
4
|
+
attribute :description, 'This is a normal badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'normal.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'normal.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:visit_paris, 'Visit Paris', 'Go to Paris')
|
15
|
+
end
|
16
|
+
|
17
|
+
def visit_paris(user, params)
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class ParameteredBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'parametered_badge'
|
3
|
+
attribute :name, 'Parametered badge'
|
4
|
+
attribute :description, 'This is a parametered_badge badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'parametered_badge.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'parametered_badge.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
hook :mastered_a_weapon, to: [:master_sword, :master_bow]
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
|
16
|
+
add_objective(:master_sword, 'Master sword', 'You shall learn the ancient secrets of chivalry')
|
17
|
+
add_objective(:master_bow, 'Master bow', 'You shall learn the ancient secrets of archery')
|
18
|
+
end
|
19
|
+
|
20
|
+
def master_sword(user, params)
|
21
|
+
weapon_checker('sword', params[:weapon_used])
|
22
|
+
end
|
23
|
+
|
24
|
+
def master_bow(user, params)
|
25
|
+
weapon_checker('bow', params[:weapon_used])
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def weapon_checker(weapon_to_master, weapon_used)
|
31
|
+
weapon_to_master == weapon_used
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class TwoObjectivesBadge < AdHonorem::Badge
|
2
|
+
attribute :slug, 'two_objectives_badge'
|
3
|
+
attribute :name, 'Two Objectives badge'
|
4
|
+
attribute :description, 'This is a two-objectives badge'
|
5
|
+
attribute :category, 'General'
|
6
|
+
attribute :points, 10
|
7
|
+
attribute :icon_locked, Rails.root.join('public', 'badges', 'locked', 'two_objectives.png')
|
8
|
+
attribute :icon_unlocked, Rails.root.join('public', 'badges', 'unlocked', 'two_objectives.png')
|
9
|
+
attribute :legacy, false
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
|
14
|
+
add_objective(:use_longbow, 'Longbow', 'Use your longbow for the first time')
|
15
|
+
add_objective(:use_sword, 'Sword', 'Use your sword 5 times', 5)
|
16
|
+
end
|
17
|
+
|
18
|
+
def use_longbow(user, params)
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
def use_sword(user, params)
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'active_record/railtie'
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
require 'action_mailer/railtie'
|
6
|
+
require 'action_view/railtie'
|
7
|
+
require 'sprockets/railtie'
|
8
|
+
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
require 'adhonorem'
|
11
|
+
|
12
|
+
module TestApp
|
13
|
+
class Application < Rails::Application
|
14
|
+
config.active_record.raise_in_transactional_callbacks = true
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = false
|
3
|
+
|
4
|
+
config.eager_load = false
|
5
|
+
|
6
|
+
config.consider_all_requests_local = true
|
7
|
+
config.action_controller.perform_caching = false
|
8
|
+
|
9
|
+
config.action_mailer.raise_delivery_errors = false
|
10
|
+
|
11
|
+
config.active_support.deprecation = :log
|
12
|
+
|
13
|
+
config.active_record.migration_error = :page_load
|
14
|
+
|
15
|
+
config.assets.debug = true
|
16
|
+
|
17
|
+
config.assets.digest = true
|
18
|
+
|
19
|
+
config.assets.raise_runtime_errors = true
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = true
|
3
|
+
|
4
|
+
config.eager_load = true
|
5
|
+
|
6
|
+
config.consider_all_requests_local = false
|
7
|
+
config.action_controller.perform_caching = true
|
8
|
+
|
9
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
10
|
+
|
11
|
+
config.assets.js_compressor = :uglifier
|
12
|
+
config.assets.compile = false
|
13
|
+
|
14
|
+
config.assets.digest = true
|
15
|
+
|
16
|
+
config.log_level = :debug
|
17
|
+
|
18
|
+
config.i18n.fallbacks = true
|
19
|
+
|
20
|
+
config.active_support.deprecation = :notify
|
21
|
+
|
22
|
+
config.log_formatter = ::Logger::Formatter.new
|
23
|
+
|
24
|
+
config.active_record.dump_schema_after_migration = false
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
config.cache_classes = true
|
3
|
+
|
4
|
+
config.eager_load = false
|
5
|
+
|
6
|
+
config.serve_static_files = true
|
7
|
+
config.static_cache_control = 'public, max-age=3600'
|
8
|
+
|
9
|
+
config.consider_all_requests_local = true
|
10
|
+
config.action_controller.perform_caching = false
|
11
|
+
|
12
|
+
config.action_dispatch.show_exceptions = false
|
13
|
+
|
14
|
+
config.action_controller.allow_forgery_protection = false
|
15
|
+
|
16
|
+
config.action_mailer.delivery_method = :test
|
17
|
+
|
18
|
+
config.active_support.test_order = :random
|
19
|
+
|
20
|
+
config.active_support.deprecation = :stderr
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.version = '1.0'
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CreateAdhonoremProgress < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :adhonorem_progresses do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.string :objective_slug
|
6
|
+
t.integer :numeric_progress, default: 0
|
7
|
+
end
|
8
|
+
bind_static_record :adhonorem_progresses, :badge
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateAdhonoremAchievement < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :adhonorem_achievements do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.integer :state, default: 0
|
6
|
+
t.datetime :unlocked_at
|
7
|
+
|
8
|
+
t.timestamps null: false
|
9
|
+
end
|
10
|
+
bind_static_record :adhonorem_achievements, :badge
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20170103065401) do
|
15
|
+
|
16
|
+
create_table "adhonorem_achievements", force: :cascade do |t|
|
17
|
+
t.integer "user_id"
|
18
|
+
t.integer "state", default: 0
|
19
|
+
t.datetime "unlocked_at"
|
20
|
+
t.datetime "created_at", null: false
|
21
|
+
t.datetime "updated_at", null: false
|
22
|
+
t.string "badge_static_record_type"
|
23
|
+
end
|
24
|
+
|
25
|
+
create_table "adhonorem_progresses", force: :cascade do |t|
|
26
|
+
t.integer "user_id"
|
27
|
+
t.string "objective_slug"
|
28
|
+
t.integer "numeric_progress", default: 0
|
29
|
+
t.string "badge_static_record_type"
|
30
|
+
end
|
31
|
+
|
32
|
+
create_table "users", force: :cascade do |t|
|
33
|
+
t.string "name"
|
34
|
+
t.integer "level"
|
35
|
+
t.datetime "created_at", null: false
|
36
|
+
t.datetime "updated_at", null: false
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|