Commit 6368c78ee9d6cad07e46b7cc39d3dc8c16cfb920
1 parent
8f30e7a2
Exists in
master
and in
29 other branches
environment_features: Add redirection_after_signup option for
Environment. (ActionItem2998)
Showing
4 changed files
with
45 additions
and
2 deletions
Show diff stats
app/models/environment.rb
@@ -145,6 +145,18 @@ class Environment < ActiveRecord::Base | @@ -145,6 +145,18 @@ class Environment < ActiveRecord::Base | ||
145 | end | 145 | end |
146 | validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true | 146 | validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true |
147 | 147 | ||
148 | + def self.signup_redirection_options | ||
149 | + { | ||
150 | + 'keep_on_same_page' => _('Stays on the same page the user was before signup.'), | ||
151 | + 'site_homepage' => _('Redirects the user to the environment homepage.'), | ||
152 | + 'user_profile_page' => _('Redirects the user to his profile page.'), | ||
153 | + 'user_homepage' => _('Redirects the user to his homepage.'), | ||
154 | + 'user_control_panel' => _('Redirects the user to his control panel.') | ||
155 | + } | ||
156 | + end | ||
157 | + validates_inclusion_of :redirection_after_signup, :in => Environment.signup_redirection_options.keys, :allow_nil => true | ||
158 | + | ||
159 | + | ||
148 | # ################################################# | 160 | # ################################################# |
149 | # Relationships and applied behaviour | 161 | # Relationships and applied behaviour |
150 | # ################################################# | 162 | # ################################################# |
db/migrate/20140205191914_add_redirection_after_signup_to_environment.rb
0 → 100644
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +class AddRedirectionAfterSignupToEnvironment < ActiveRecord::Migration | ||
2 | + def self.up | ||
3 | + add_column :environments, :redirection_after_signup, :string, :default => 'keep_on_same_page' | ||
4 | + end | ||
5 | + | ||
6 | + def self.down | ||
7 | + remove_column :environments, :redirection_after_signup | ||
8 | + end | ||
9 | +end |
db/schema.rb
1 | -# This file is auto-generated from the current state of the database. Instead of editing this file, | 1 | +# This file is auto-generated from the current state of the database. Instead of editing this file, |
2 | # please use the migrations feature of Active Record to incrementally modify your database, and | 2 | # please use the migrations feature of Active Record to incrementally modify your database, and |
3 | # then regenerate this schema definition. | 3 | # then regenerate this schema definition. |
4 | # | 4 | # |
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | # | 9 | # |
10 | # It's strongly recommended to check this file into your version control system. | 10 | # It's strongly recommended to check this file into your version control system. |
11 | 11 | ||
12 | -ActiveRecord::Schema.define(:version => 20140108132730) do | 12 | +ActiveRecord::Schema.define(:version => 20140205191914) do |
13 | 13 | ||
14 | create_table "abuse_reports", :force => true do |t| | 14 | create_table "abuse_reports", :force => true do |t| |
15 | t.integer "reporter_id" | 15 | t.integer "reporter_id" |
@@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version => 20140108132730) do | @@ -282,6 +282,7 @@ ActiveRecord::Schema.define(:version => 20140108132730) do | ||
282 | t.text "signup_welcome_text" | 282 | t.text "signup_welcome_text" |
283 | t.string "languages" | 283 | t.string "languages" |
284 | t.string "default_language" | 284 | t.string "default_language" |
285 | + t.string "redirection_after_signup", :default => "keep_on_same_page" | ||
285 | end | 286 | end |
286 | 287 | ||
287 | create_table "external_feeds", :force => true do |t| | 288 | create_table "external_feeds", :force => true do |t| |
test/unit/environment_test.rb
@@ -1220,6 +1220,27 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -1220,6 +1220,27 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
1220 | end | 1220 | end |
1221 | end | 1221 | end |
1222 | 1222 | ||
1223 | + should 'return a Hash on signup redirection options' do | ||
1224 | + assert_kind_of Hash, Environment.signup_redirection_options | ||
1225 | + end | ||
1226 | + | ||
1227 | + should 'respond to redirection after signup' do | ||
1228 | + assert_respond_to Environment.new, :redirection_after_signup | ||
1229 | + end | ||
1230 | + | ||
1231 | + should 'allow only environment signup redirection options' do | ||
1232 | + environment = fast_create(Environment) | ||
1233 | + environment.redirection_after_signup = 'invalid_option' | ||
1234 | + environment.save | ||
1235 | + assert environment.errors.invalid?(:redirection_after_signup) | ||
1236 | + | ||
1237 | + Environment.signup_redirection_options.keys.each do |redirection| | ||
1238 | + environment.redirection_after_signup = redirection | ||
1239 | + environment.save | ||
1240 | + assert !environment.errors.invalid?(:redirection_after_signup) | ||
1241 | + end | ||
1242 | + end | ||
1243 | + | ||
1223 | should 'respond to signup_welcome_text' do | 1244 | should 'respond to signup_welcome_text' do |
1224 | assert_respond_to Environment.new, :signup_welcome_text | 1245 | assert_respond_to Environment.new, :signup_welcome_text |
1225 | end | 1246 | end |