From 7a5a843993ad8502bfe1a290d0b0a5f3d9692bf3 Mon Sep 17 00:00:00 2001 From: radhika <radhika@curoverse.com> Date: Fri, 8 Aug 2014 21:47:25 -0400 Subject: [PATCH] 3296: update tests --- .../app/controllers/application_controller.rb | 5 +++-- apps/workbench/app/views/users/profile.html.erb | 10 ++++------ .../test/integration/application_layout_test.rb | 17 ++++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 2113eba2a5..cd74dffdfd 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -529,8 +529,9 @@ class ApplicationController < ActionController::Base if current_user && profile_config missing_required_profile = false - user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs - user_prefs = current_user.prefs if !user_prefs[:profile] + user_prefs = current_user.prefs + current_user.reload if !user_prefs[:profile] + user_prefs = current_user.prefs current_user_profile = user_prefs[:profile] if user_prefs profile_config.kind_of?(Array) && profile_config.andand.each do |entry| diff --git a/apps/workbench/app/views/users/profile.html.erb b/apps/workbench/app/views/users/profile.html.erb index 620b3ee459..193c8b5115 100644 --- a/apps/workbench/app/views/users/profile.html.erb +++ b/apps/workbench/app/views/users/profile.html.erb @@ -1,8 +1,6 @@ <% profile_config = Rails.configuration.user_profile_form_fields - this_user = User.limit(1).where(uuid: current_user.uuid).first - user_prefs = User.limit(1).where(uuid: current_user.uuid).first.prefs - current_user_profile = user_prefs[:profile] if user_prefs + current_user_profile = current_user.prefs[:profile] show_save_button = false %> @@ -49,7 +47,7 @@ <div class="form-group"> <label for="identity_url" class="col-sm-3 control-label"> Identity URL </label> <div class="col-sm-9"> - <p class="form-control-static" id="identity_url" name="identity_url"><%=this_user.andand.identity_url%></p> + <p class="form-control-static" id="identity_url" name="identity_url"><%=current_user.andand.identity_url%></p> </div> </div> @@ -68,7 +66,7 @@ </label> <% if entry['type'] == 'select' %> <div class="col-sm-9"> - <select class="form-control" id="user[prefs][:profile][:<%=entry['key']%>]" name="user[prefs][:profile][:<%=entry['key']%>]"> + <select class="form-control" name="user[prefs][:profile][:<%=entry['key']%>]"> <% entry['options'].each do |option| %> <option value="<%=option%>" <%='selected' if option==value%>><%=option%></option> <% end %> @@ -76,7 +74,7 @@ </div> <% else %> <div class="col-sm-9"> - <input type="text" class="form-control" id="user[prefs][:profile][:<%=entry['key']%>]" name="user[prefs][:profile][:<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input> + <input type="text" class="form-control" name="user[prefs][:profile][:<%=entry['key']%>]" placeholder="<%=entry['form_field_description']%>" value="<%=value%>" ></input> </div> <% end %> </div> diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb index f4a56a213a..f4b9880825 100644 --- a/apps/workbench/test/integration/application_layout_test.rb +++ b/apps/workbench/test/integration/application_layout_test.rb @@ -200,8 +200,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest assert page.has_text? profile_message assert page.has_text? required_field_title - - page.find_field(required_field_key).set 'value to fill required field' + page.find_field('user[prefs][:profile][:'+required_field_key+']').set 'value to fill required field' click_button "Save profile" @@ -245,11 +244,11 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest end [ -# [nil, nil, false, false], -# ['inactive', api_fixture('users')['inactive'], true, false], -# ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false], -# ['active', api_fixture('users')['active'], true, true], -# ['admin', api_fixture('users')['admin'], true, true], + [nil, nil, false, false], + ['inactive', api_fixture('users')['inactive'], true, false], + ['inactive_uninvited', api_fixture('users')['inactive_uninvited'], false, false], + ['active', api_fixture('users')['active'], true, true], + ['admin', api_fixture('users')['admin'], true, true], ['active_no_prefs', api_fixture('users')['active_no_prefs'], true, false], ].each do |token, user, invited, has_profile| test "visit home page when profile is configured for user #{token}" do @@ -263,7 +262,7 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest verify_homepage_with_profile user, invited, has_profile end end -=begin + [ [nil, nil, false, false], ['inactive', api_fixture('users')['inactive'], true, false], @@ -284,5 +283,5 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest verify_homepage_with_profile user, invited, has_profile end end -=end + end -- 2.30.2