Skip to content

Commit 488f91b

Browse files
committed
Merge pull request #33 from namick/rails-v4.2.0
Support Rails 4.2.0
2 parents 1eb490e + 127515f commit 488f91b

File tree

122 files changed

+3653
-547
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+3653
-547
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.bundle/
22
log/*.log
33
pkg/
4-
spec/dummy/db/*.sqlite3
54
spec/dummy/log/*.log
65
spec/dummy/tmp/
76
spec/dummy/.sass-cache

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: ruby
22
rvm:
33
- 1.9.3
4-
before_script:
5-
- cd spec/dummy && bundle exec rake db:test:load && cd -
4+
- 2.1.1

Gemfile.lock

Lines changed: 60 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,49 @@ PATH
22
remote: .
33
specs:
44
obfuscate_id (0.0.4)
5-
activeresource (~> 4.0.0)
6-
rails (~> 4.1.8)
5+
rails (~> 4.2.0)
76
scatter_swap (~> 0.0.3)
87

98
GEM
109
remote: http://rubygems.org/
1110
specs:
12-
actionmailer (4.1.8)
13-
actionpack (= 4.1.8)
14-
actionview (= 4.1.8)
11+
actionmailer (4.2.0)
12+
actionpack (= 4.2.0)
13+
actionview (= 4.2.0)
14+
activejob (= 4.2.0)
1515
mail (~> 2.5, >= 2.5.4)
16-
actionpack (4.1.8)
17-
actionview (= 4.1.8)
18-
activesupport (= 4.1.8)
19-
rack (~> 1.5.2)
16+
rails-dom-testing (~> 1.0, >= 1.0.5)
17+
actionpack (4.2.0)
18+
actionview (= 4.2.0)
19+
activesupport (= 4.2.0)
20+
rack (~> 1.6.0)
2021
rack-test (~> 0.6.2)
21-
actionview (4.1.8)
22-
activesupport (= 4.1.8)
22+
rails-dom-testing (~> 1.0, >= 1.0.5)
23+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
24+
actionview (4.2.0)
25+
activesupport (= 4.2.0)
2326
builder (~> 3.1)
2427
erubis (~> 2.7.0)
25-
activemodel (4.1.8)
26-
activesupport (= 4.1.8)
28+
rails-dom-testing (~> 1.0, >= 1.0.5)
29+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
30+
activejob (4.2.0)
31+
activesupport (= 4.2.0)
32+
globalid (>= 0.3.0)
33+
activemodel (4.2.0)
34+
activesupport (= 4.2.0)
2735
builder (~> 3.1)
28-
activerecord (4.1.8)
29-
activemodel (= 4.1.8)
30-
activesupport (= 4.1.8)
31-
arel (~> 5.0.0)
32-
activeresource (4.0.0)
33-
activemodel (~> 4.0)
34-
activesupport (~> 4.0)
35-
rails-observers (~> 0.1.1)
36-
activesupport (4.1.8)
37-
i18n (~> 0.6, >= 0.6.9)
36+
activerecord (4.2.0)
37+
activemodel (= 4.2.0)
38+
activesupport (= 4.2.0)
39+
arel (~> 6.0)
40+
activesupport (4.2.0)
41+
i18n (~> 0.7)
3842
json (~> 1.7, >= 1.7.7)
3943
minitest (~> 5.1)
40-
thread_safe (~> 0.1)
44+
thread_safe (~> 0.3, >= 0.3.4)
4145
tzinfo (~> 1.1)
4246
addressable (2.3.6)
43-
arel (5.0.1.20140414130214)
47+
arel (6.0.0)
4448
builder (3.2.2)
4549
capybara (2.4.4)
4650
mime-types (>= 1.16)
@@ -57,6 +61,8 @@ GEM
5761
erubis (2.7.0)
5862
ffi (1.9.6)
5963
formatador (0.2.5)
64+
globalid (0.3.2)
65+
activesupport (>= 4.1.0)
6066
guard (2.10.2)
6167
formatador (>= 0.2.4)
6268
listen (~> 2.7)
@@ -75,46 +81,55 @@ GEM
7581
spork (>= 0.8.4)
7682
hike (1.2.3)
7783
hitimes (1.2.2)
78-
i18n (0.6.11)
79-
json (1.8.1)
84+
i18n (0.7.0)
85+
json (1.8.2)
8086
launchy (2.4.3)
8187
addressable (~> 2.3)
8288
listen (2.8.3)
8389
celluloid (>= 0.15.2)
8490
rb-fsevent (>= 0.9.3)
8591
rb-inotify (>= 0.9)
92+
loofah (2.0.1)
93+
nokogiri (>= 1.5.9)
8694
lumberjack (1.0.9)
8795
mail (2.6.3)
8896
mime-types (>= 1.16, < 3)
8997
method_source (0.8.2)
9098
mime-types (2.4.3)
9199
mini_portile (0.6.1)
92-
minitest (5.5.0)
100+
minitest (5.5.1)
93101
multi_json (1.10.1)
94102
nokogiri (1.6.5)
95103
mini_portile (~> 0.6.0)
96104
pry (0.10.1)
97105
coderay (~> 1.1.0)
98106
method_source (~> 0.8.1)
99107
slop (~> 3.4)
100-
rack (1.5.2)
101-
rack-test (0.6.2)
108+
rack (1.6.0)
109+
rack-test (0.6.3)
102110
rack (>= 1.0)
103-
rails (4.1.8)
104-
actionmailer (= 4.1.8)
105-
actionpack (= 4.1.8)
106-
actionview (= 4.1.8)
107-
activemodel (= 4.1.8)
108-
activerecord (= 4.1.8)
109-
activesupport (= 4.1.8)
111+
rails (4.2.0)
112+
actionmailer (= 4.2.0)
113+
actionpack (= 4.2.0)
114+
actionview (= 4.2.0)
115+
activejob (= 4.2.0)
116+
activemodel (= 4.2.0)
117+
activerecord (= 4.2.0)
118+
activesupport (= 4.2.0)
110119
bundler (>= 1.3.0, < 2.0)
111-
railties (= 4.1.8)
112-
sprockets-rails (~> 2.0)
113-
rails-observers (0.1.2)
114-
activemodel (~> 4.0)
115-
railties (4.1.8)
116-
actionpack (= 4.1.8)
117-
activesupport (= 4.1.8)
120+
railties (= 4.2.0)
121+
sprockets-rails
122+
rails-deprecated_sanitizer (1.0.3)
123+
activesupport (>= 4.2.0.alpha)
124+
rails-dom-testing (1.0.5)
125+
activesupport (>= 4.2.0.beta, < 5.0)
126+
nokogiri (~> 1.6.0)
127+
rails-deprecated_sanitizer (>= 1.0.1)
128+
rails-html-sanitizer (1.0.1)
129+
loofah (~> 2.0)
130+
railties (4.2.0)
131+
actionpack (= 4.2.0)
132+
activesupport (= 4.2.0)
118133
rake (>= 0.8.7)
119134
thor (>= 0.18.1, < 2.0)
120135
rake (10.4.2)
@@ -149,7 +164,7 @@ GEM
149164
multi_json (~> 1.0)
150165
rack (~> 1.0)
151166
tilt (~> 1.1, != 1.3.0)
152-
sprockets-rails (2.2.2)
167+
sprockets-rails (2.2.4)
153168
actionpack (>= 3.0)
154169
activesupport (>= 3.0)
155170
sprockets (>= 2.8, < 4.0)

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ obfuscate_id turns a URL like this:
1313
into something like:
1414

1515
http://example.com/users/2356513904
16-
16+
1717
Sequential ActiveRecord ids become non-sequential, random looking, numeric ids.
1818

1919
# post 7000
@@ -22,7 +22,7 @@ Sequential ActiveRecord ids become non-sequential, random looking, numeric ids.
2222
http://example.com/posts/7107163820
2323
# post 7002
2424
http://example.com/posts/3296163828
25-
25+
2626
## Why would you want this?
2727

2828
If your site is scaling well, you might not want to leak that you are getting 50 new posts a minute.
@@ -52,7 +52,7 @@ Run bundler.
5252

5353
## Usage
5454

55-
In your model, add a single line.
55+
In your model, add a single line.
5656

5757
class Post < ActiveRecord::Base
5858
obfuscate_id
@@ -81,6 +81,12 @@ ActiveRecord reverses this obfuscated id back to the plain id before building th
8181
* This is not security. obfuscate_id was created to lightly mask record id numbers for the casual user. If you need to really secure your database ids (hint, you probably don't), you need to use real encryption like AES.
8282
* To properly generate obfuscated urls, make sure you trigger the model's `to_param` method by passing in the whole object rather than just the id; do this: `post_path(@post)` not this: `post_path(@post.id)`.
8383

84+
## Versions
85+
86+
This is tested with Rails 4.2.0. For other versions of Rails, please see [the releases](https://github.com/namick/obfuscate_id/releases).
87+
88+
If you are trying to get it to work with a different version of rails that is not tested, let me know in [the issues](https://github.com/namick/obfuscate_id/issues)
89+
8490
## Development
8591

8692
To run the tests, first clone the repo and run bundler:
@@ -89,12 +95,6 @@ To run the tests, first clone the repo and run bundler:
8995
cd obfuscate_id
9096
bundle install
9197

92-
Change to the dummy rails app and load the test database
93-
94-
cd spec/dummy
95-
bundle exec rake db:test:load
96-
cd -
97-
9898
Run the tests
9999

100100
bundle exec rspec spec

lib/obfuscate_id.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,20 @@ def to_param
5959

6060
# As ActiveRecord::Persistence#reload uses self.id
6161
# reload without deobfuscating
62-
# def reload(options = nil)
63-
# options = (options || {}).merge(:no_obfuscated_id => true)
64-
# super(options)
65-
# end
66-
6762
def reload(options = nil)
68-
options = (options || {}).merge(:no_obfuscated_id => true)
63+
options = (options || {}).merge(no_obfuscated_id: true)
6964
clear_aggregation_cache
7065
clear_association_cache
66+
7167
fresh_object =
7268
if options && options[:lock]
7369
self.class.unscoped { self.class.lock(options[:lock]).find(id, options) }
7470
else
7571
self.class.unscoped { self.class.find(id, options) }
7672
end
7773

78-
@attributes.update(fresh_object.instance_variable_get('@attributes'))
79-
80-
@column_types = self.class.column_types
81-
@column_types_override = fresh_object.instance_variable_get('@column_types_override')
82-
@attributes_cache = {}
83-
@new_record = false
74+
@attributes = fresh_object.instance_variable_get('@attributes')
75+
@new_record = false
8476
self
8577
end
8678

obfuscate_id.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
1717
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"]
1818

1919
s.add_dependency "scatter_swap", "~> 0.0.3"
20-
s.add_dependency "rails", "~> 4.1.8"
21-
s.add_dependency "activeresource", "~> 4.0.0"
20+
s.add_dependency "rails", "~> 4.2.0"
2221

2322
s.add_development_dependency "sqlite3"
2423
s.add_development_dependency "rspec-rails"

spec/dummy/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
2+
#
3+
# If you find yourself ignoring temporary files generated by your text editor
4+
# or operating system, you probably want to add a global ignore instead:
5+
# git config --global core.excludesfile '~/.gitignore_global'
6+
7+
# Ignore bundler config.
8+
/.bundle
9+
10+
# Ignore the default SQLite database.
11+
/db/development.sqlite3
12+
/db/*.sqlite3-journal
13+
14+
# Ignore all logfiles and tempfiles.
15+
/log/*
16+
!/log/.keep
17+
/tmp

spec/dummy/Gemfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
source 'https://rubygems.org'
2+
3+
4+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5+
gem 'rails', '4.2.0'
6+
# Use sqlite3 as the database for Active Record
7+
gem 'sqlite3'
8+
# Use SCSS for stylesheets
9+
gem 'sass-rails', '~> 5.0'
10+
# Use Uglifier as compressor for JavaScript assets
11+
gem 'uglifier', '>= 1.3.0'
12+
# Use CoffeeScript for .coffee assets and views
13+
gem 'coffee-rails', '~> 4.1.0'
14+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
15+
# gem 'therubyracer', platforms: :ruby
16+
17+
# Use jquery as the JavaScript library
18+
gem 'jquery-rails'
19+
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20+
gem 'turbolinks'
21+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22+
gem 'jbuilder', '~> 2.0'
23+
# bundle exec rake doc:rails generates the API under doc/api.
24+
gem 'sdoc', '~> 0.4.0', group: :doc
25+
26+
# Use ActiveModel has_secure_password
27+
# gem 'bcrypt', '~> 3.1.7'
28+
29+
# Use Unicorn as the app server
30+
# gem 'unicorn'
31+
32+
# Use Capistrano for deployment
33+
# gem 'capistrano-rails', group: :development
34+
35+
group :development, :test do
36+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
37+
gem 'byebug'
38+
39+
# Access an IRB console on exception pages or by using <%= console %> in views
40+
gem 'web-console', '~> 2.0'
41+
42+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
43+
gem 'spring'
44+
end
45+

0 commit comments

Comments
 (0)