Permalink
Browse files

fixed test and code to accomodate rails 4

  • Loading branch information...
1 parent 51cd387 commit 0f02d7aad93d5988b4bf3ee1b0eb9cf973ebb013 @Systho Systho committed Jan 10, 2013
Showing with 197 additions and 143 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 Gemfile
  3. +76 −56 Gemfile.lock
  4. +10 −7 app/controllers/masq/accounts_controller.rb
  5. +11 −2 app/controllers/masq/personas_controller.rb
  6. +13 −7 app/controllers/masq/server_controller.rb
  7. +5 −1 app/controllers/masq/sites_controller.rb
  8. +4 −4 app/models/masq/account.rb
  9. +1 −1 app/models/masq/open_id_request.rb
  10. +1 −1 app/models/masq/persona.rb
  11. +1 −1 app/models/masq/release_policy.rb
  12. +1 −1 app/models/masq/site.rb
  13. +1 −1 app/views/masq/personas/index.html.erb
  14. +35 −6 app/views/masq/server/decide.html.erb
  15. +1 −1 app/views/masq/sites/edit.html.erb
  16. +1 −1 app/views/masq/sites/index.html.erb
  17. +6 −6 config/routes.rb
  18. +1 −1 lib/masq/active_record_openid_store/association.rb
  19. +1 −1 lib/masq/active_record_openid_store/nonce.rb
  20. +1 −1 masq.gemspec
  21. +0 −5 test/dummy/config/application.rb
  22. +5 −20 test/dummy/config/database.yml
  23. +2 −4 test/dummy/config/environments/development.rb
  24. +2 −0 test/dummy/config/environments/production.rb
  25. +2 −4 test/dummy/config/environments/test.rb
  26. +1 −1 test/dummy/config/initializers/secret_token.rb
  27. +0 −1 test/functional/masq/accounts_controller_test.rb
  28. +0 −1 test/functional/masq/info_controller_test.rb
  29. +0 −1 test/functional/masq/passwords_controller_test.rb
  30. +0 −1 test/functional/masq/personas_controller_test.rb
  31. +0 −1 test/functional/masq/server_controller_test.rb
  32. +1 −1 test/functional/masq/sessions_controller_test.rb
  33. +1 −2 test/functional/masq/sites_controller_test.rb
  34. +1 −1 test/functional/masq/yubikey_associations_controller_test.rb
  35. +1 −1 test/integration/openid_user_stories_test.rb
  36. +4 −0 test/test_helper.rb
View
@@ -17,3 +17,5 @@ test/dummy/tmp
test/dummy/.sass-cache
tmp
vendor/ruby
+.idea
+.rbenv-version
View
@@ -17,6 +17,11 @@ group :development, :test do
gem 'ruby_gntp'
gem 'guard-minitest'
gem 'rb-fsevent', :require => false
+
+ # rails 4 is still in beta not in rc
+ gem 'rails', :github => 'rails/rails', :branch => 'master'
+ gem 'journey', :github => 'rails/journey', :branch => 'master'
+ gem 'arel', :github => 'rails/arel', :branch => 'master'
end
gemspec
View
@@ -1,46 +1,77 @@
+GIT
+ remote: git://github.com/rails/arel.git
+ revision: 38d0a222e275d917a2c1d093b24457bafb600a00
+ branch: master
+ specs:
+ arel (3.0.2.20120819075748)
+
+GIT
+ remote: git://github.com/rails/journey.git
+ revision: e64274443f8420df2518cf2206a2c640d9d8e196
+ branch: master
+ specs:
+ journey (2.0.0.20120723141804)
+
+GIT
+ remote: git://github.com/rails/rails.git
+ revision: ffa9540fd361eb34c445568b66abf283b9e658f8
+ branch: master
+ specs:
+ actionmailer (4.0.0.beta)
+ actionpack (= 4.0.0.beta)
+ mail (~> 2.5.3)
+ actionpack (4.0.0.beta)
+ activesupport (= 4.0.0.beta)
+ builder (~> 3.1.0)
+ erubis (~> 2.7.0)
+ rack (~> 1.4.3)
+ rack-test (~> 0.6.1)
+ activemodel (4.0.0.beta)
+ activesupport (= 4.0.0.beta)
+ builder (~> 3.1.0)
+ activerecord (4.0.0.beta)
+ activemodel (= 4.0.0.beta)
+ activerecord-deprecated_finders (= 0.0.1)
+ activesupport (= 4.0.0.beta)
+ arel (~> 3.0.2)
+ activesupport (4.0.0.beta)
+ i18n (~> 0.6)
+ minitest (~> 4.1)
+ multi_json (~> 1.3)
+ thread_safe (~> 0.1)
+ tzinfo (~> 0.3.33)
+ rails (4.0.0.beta)
+ actionmailer (= 4.0.0.beta)
+ actionpack (= 4.0.0.beta)
+ activerecord (= 4.0.0.beta)
+ activesupport (= 4.0.0.beta)
+ bundler (>= 1.3.0.pre.4, < 2.0)
+ railties (= 4.0.0.beta)
+ sprockets-rails (~> 2.0.0.rc1)
+ railties (4.0.0.beta)
+ actionpack (= 4.0.0.beta)
+ activesupport (= 4.0.0.beta)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (>= 0.15.4, < 2.0)
+
PATH
remote: .
specs:
masq (0.2.5)
i18n_data
- rails (~> 3.2.0)
+ rails (~> 4.0.0.beta)
ruby-openid
ruby-yadis
yubikey
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.11)
- actionpack (= 3.2.11)
- mail (~> 2.4.4)
- actionpack (3.2.11)
- activemodel (= 3.2.11)
- activesupport (= 3.2.11)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.0)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
- activemodel (3.2.11)
- activesupport (= 3.2.11)
- builder (~> 3.0.0)
- activerecord (3.2.11)
- activemodel (= 3.2.11)
- activesupport (= 3.2.11)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.11)
- activemodel (= 3.2.11)
- activesupport (= 3.2.11)
- activesupport (3.2.11)
- i18n (~> 0.6)
- multi_json (~> 1.0)
+ activerecord-deprecated_finders (0.0.1)
ansi (1.4.3)
- arel (3.0.2)
- builder (3.0.4)
+ atomic (1.0.1)
+ builder (3.1.4)
crypt19 (1.2.1)
erubis (2.7.0)
guard (1.3.2)
@@ -50,57 +81,43 @@ GEM
guard (>= 0.4)
hike (1.2.1)
i18n (0.6.1)
- i18n_data (0.3.2)
- journey (1.0.4)
+ i18n_data (0.3.3)
json (1.7.6)
listen (0.5.0)
- mail (2.4.4)
+ mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
metaclass (0.0.1)
mime-types (1.19)
- minitest (3.4.0)
- mocha (0.12.4)
+ minitest (4.4.0)
+ mocha (0.13.1)
metaclass (~> 0.0.1)
multi_json (1.5.0)
polyglot (0.3.3)
rack (1.4.3)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-ssl (1.3.2)
- rack
rack-test (0.6.2)
rack (>= 1.0)
- rails (3.2.11)
- actionmailer (= 3.2.11)
- actionpack (= 3.2.11)
- activerecord (= 3.2.11)
- activeresource (= 3.2.11)
- activesupport (= 3.2.11)
- bundler (~> 1.0)
- railties (= 3.2.11)
- railties (3.2.11)
- actionpack (= 3.2.11)
- activesupport (= 3.2.11)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rb-fsevent (0.9.1)
rdoc (3.12)
json (~> 1.4)
- ruby-openid (2.2.0)
+ ruby-openid (2.2.2)
ruby-yadis (0.3.4)
ruby_gntp (0.3.4)
- sprockets (2.2.2)
+ sprockets (2.8.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ sprockets-rails (2.0.0.rc1)
+ actionpack (>= 3.0)
+ activesupport (>= 3.0)
+ sprockets (~> 2.8)
sqlite3 (1.3.6)
thor (0.16.0)
+ thread_safe (0.1.0)
+ atomic
tilt (1.3.3)
treetop (1.4.12)
polyglot
@@ -115,10 +132,13 @@ PLATFORMS
ruby
DEPENDENCIES
+ arel!
guard-minitest
+ journey!
masq!
minitest
mocha
+ rails!
rb-fsevent
ruby_gntp
sqlite3
@@ -22,9 +22,8 @@ def new
def create
cookies.delete :auth_token
- attrs = params[:account]
- attrs[:login] = attrs[:email] if email_as_login?
- signup = Signup.create_account!(attrs)
+ account_params[:login] = account_params[:email] if email_as_login?
+ signup = Signup.create_account!(account_params)
if signup.succeeded?
redirect_to login_path, :notice => signup.send_activation_email? ?
t(:thanks_for_signing_up_activation_link) :
@@ -36,11 +35,10 @@ def create
end
def update
- attrs = params[:account]
- attrs.delete(:email) if email_as_login?
- attrs.delete(:login)
+ account_params.delete(:email) if email_as_login?
+ account_params.delete(:login)
- if current_account.update_attributes(attrs)
+ if current_account.update_attributes(account_params)
redirect_to edit_account_path(:account => current_account), :notice => t(:profile_updated)
else
render :action => 'edit'
@@ -120,5 +118,10 @@ def detect_xrds
params[:account] = $1
end
end
+
+ def account_params
+ @account_params ||= params.require(:account).permit(:login, :email, :password, :password_confirmation, :public_persona_id, :yubikey_mandatory)
+ end
+
end
end
@@ -13,6 +13,11 @@ def index
end
end
+ def new
+ @persona = current_account.personas.new
+ end
+
+
def create
respond_to do |format|
if persona.save!
@@ -26,7 +31,7 @@ def create
def update
respond_to do |format|
- if persona.update_attributes(params[:persona])
+ if persona.update_attributes(persona_params)
flash[:notice] = t(:persona_updated)
format.html { redirect_back_or_default account_personas_path }
else
@@ -51,9 +56,13 @@ def destroy
def persona
@persona ||= params[:id].present? ?
current_account.personas.find(params[:id]) :
- current_account.personas.new(params[:persona])
+ current_account.personas.new(persona_params)
end
+ def persona_params
+ params.require(:persona).permit(:title)
+ end
+
def redirect_back_or_default(default)
case session[:return_to]
when decide_path then redirect_to decide_path(:persona_id => persona.id)
@@ -62,8 +62,8 @@ def proceed
# Displays the decision page on that the user can confirm the request and
# choose which data should be transfered to the relying party.
def decide
- @site = current_account.sites.find_or_initialize_by_url(checkid_request.trust_root)
- @site.persona = current_account.personas.find(params[:persona_id] || :first) if sreg_request || ax_store_request || ax_fetch_request
+ @site = current_account.sites.find_or_initialize_by(url: checkid_request.trust_root)
+ @site.persona = current_account.personas.where(params[:persona_id] ).first || current_account.personas.first if sreg_request || ax_store_request || ax_fetch_request
end
# This action is called by submitting the decision form, the information entered by
@@ -75,13 +75,13 @@ def complete
else
resp = checkid_request.answer(true, nil, identifier(current_account))
if params[:always]
- @site = current_account.sites.find_or_create_by_persona_id_and_url(params[:site][:persona_id], params[:site][:url])
- @site.update_attributes(params[:site])
+ @site = current_account.sites.where(persona_id: params[:site][:persona_id], url: params[:site][:url]).first_or_create
+ @site.update_attributes(site_params)
elsif sreg_request || ax_fetch_request
- @site = current_account.sites.find_or_initialize_by_persona_id_and_url(params[:site][:persona_id], params[:site][:url])
- @site.attributes = params[:site]
+ @site = current_account.sites.where(persona_id: params[:site][:persona_id], url: params[:site][:url]).first_or_create
+ @site.attributes = site_params
elsif ax_store_request
- @site = current_account.sites.find_or_initialize_by_persona_id_and_url(params[:site][:persona_id], params[:site][:url])
+ @site = current_account.sites.where(persona_id: params[:site][:persona_id], url: params[:site][:url]).first_or_create
not_supported, not_accepted, accepted = [], [], []
ax_store_request.data.each do |type_uri, values|
if property = Persona.attribute_name_for_type_uri(type_uri)
@@ -228,5 +228,11 @@ def auth_policies
[OpenID::PAPE::AUTH_MULTI_FACTOR, OpenID::PAPE::AUTH_PHISHING_RESISTANT] :
[]
end
+
+ def site_params
+ authorized_params = params.require(:site).permit( :persona_id , :url )
+ additional_data = params[:site].slice(:ax_fetch, :sreg, :properties)
+ authorized_params.merge(additional_data)
+ end
end
end
@@ -19,7 +19,7 @@ def edit
def update
respond_to do |format|
- if site.update_attributes(params[:site])
+ if site.update_attributes(site_params)
flash[:notice] = t(:release_policy_for_site_updated)
format.html { redirect_to edit_account_site_path(site) }
else
@@ -49,5 +49,9 @@ def persona
def find_personas
@personas = current_account.personas.order(:title)
end
+
+ def site_params
+ params.require(:site).permit!
+ end
end
end
@@ -2,17 +2,17 @@
module Masq
class Account < ActiveRecord::Base
- has_many :personas, :dependent => :delete_all, :order => 'id ASC'
+ has_many :personas, ->(){order(:id)}, :dependent => :delete_all
has_many :sites, :dependent => :destroy
belongs_to :public_persona, :class_name => "Persona"
validates_presence_of :login
validates_length_of :login, :within => 3..254
validates_uniqueness_of :login, :case_sensitive => false
- validates_format_of :login, :with => /^[A-Za-z0-9_@.-]+$/
+ validates_format_of :login, :with => /\A[A-Za-z0-9_@.-]+\z/
validates_presence_of :email
validates_uniqueness_of :email, :case_sensitive => false
- validates_format_of :email, :with => /(^([^@\s]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})$)|(^$)/i
+ validates_format_of :email, :with => /(\A([^@\s]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})\z)/i, :allow_blank => true
validates_presence_of :password, :if => :password_required?
validates_presence_of :password_confirmation, :if => :password_required?
validates_length_of :password, :within => 6..40, :if => :password_required?
@@ -23,7 +23,7 @@ class Account < ActiveRecord::Base
before_save :encrypt_password
after_save :deliver_forgot_password
- attr_accessible :login, :email, :password, :password_confirmation, :public_persona_id, :yubikey_mandatory
+ #attr_accessible :login, :email, :password, :password_confirmation, :public_persona_id, :yubikey_mandatory
attr_accessor :password
class ActivationCodeNotFound < StandardError; end
@@ -4,7 +4,7 @@ class OpenIdRequest < ActiveRecord::Base
before_validation :make_token, :on => :create
- attr_accessible :parameters
+ #attr_accessible :parameters
serialize :parameters, Hash
def parameters=(params)
@@ -9,7 +9,7 @@ class Persona < ActiveRecord::Base
before_destroy :check_deletable!
- attr_protected :account_id, :deletable
+ #attr_protected :account_id, :deletable
class NotDeletable < StandardError; end
Oops, something went wrong.

0 comments on commit 0f02d7a

Please sign in to comment.