Permalink
Browse files

Revert "Merge pull request #30 from alphagov/removing_need_to_specify…

…_requester_email"

This reverts commit 043e678, reversing
changes made to 2b3e204.

Since redis isn't yet production-ready, we're backing this change out
  • Loading branch information...
1 parent ca48ddb commit 156bb7058fa0ae0d948e369da84906543eb62121 @benilovj benilovj committed Jan 21, 2013
View
@@ -24,7 +24,6 @@ if ENV['GDS_ZENDESK_DEV']
else
gem "gds_zendesk", '0.0.4'
end
-gem 'redis-rails', '3.2.3'
group :test do
gem "mocha", "0.12.6", require: false
View
@@ -182,23 +182,6 @@ GEM
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
- redis (3.0.2)
- redis-actionpack (3.2.3)
- actionpack (~> 3.2.3)
- redis-rack (~> 1.4.0)
- redis-store (~> 1.1.0)
- redis-activesupport (3.2.3)
- activesupport (~> 3.2.3)
- redis-store (~> 1.1.0)
- redis-rack (1.4.2)
- rack (~> 1.4.1)
- redis-store (~> 1.1.0)
- redis-rails (3.2.3)
- redis-actionpack (~> 3.2.3)
- redis-activesupport (~> 3.2.3)
- redis-store (~> 1.1.0)
- redis-store (1.1.3)
- redis (>= 2.2.0)
rubyzip (0.9.9)
sass (3.2.5)
sass-rails (3.2.6)
@@ -275,7 +258,6 @@ DEPENDENCIES
plek (= 1.0.0)
poltergeist (= 0.7.0)
rails (= 3.2.11)
- redis-rails (= 3.2.3)
sass-rails (~> 3.2.3)
shoulda (~> 3.3.2)
therubyracer (~> 0.9.4)
@@ -13,7 +13,6 @@
//= require jquery
//= require jquery_ujs
//= require jquery.ui.datepicker
-//= require twitter/bootstrap/dropdown
//= require twitter/bootstrap/collapse
//= require_tree .
@@ -5,7 +5,7 @@
class CreateNewUserRequestsController < RequestsController
protected
def new_request
- CreateNewUserRequest.new(requested_user: RequestedUser.new)
+ CreateNewUserRequest.new(requester: Requester.new, requested_user: RequestedUser.new)
end
def zendesk_ticket_class
@@ -3,7 +3,7 @@
class RemoveUserRequestsController < RequestsController
protected
def new_request
- RemoveUserRequest.new(time_constraint: TimeConstraint.new)
+ RemoveUserRequest.new(:requester => Requester.new, :time_constraint => TimeConstraint.new)
end
def zendesk_ticket_class
@@ -8,8 +8,6 @@ def new
def create
@request = parse_request_from_params
- set_logged_in_user_as_requester_on(@request)
-
if @request.valid?
process_valid_request(@request)
else
@@ -23,12 +21,6 @@ def process_valid_request(submitted_request)
end
private
- def set_logged_in_user_as_requester_on(request)
- request.requester ||= Requester.new
- request.requester.name = current_user.name
- request.requester.email = current_user.email
- end
-
def raise_ticket(ticket)
ticket = ZendeskTickets.new(GDS_ZENDESK_CLIENT).raise_ticket(ticket)
@@ -0,0 +1,23 @@
+require 'gds-sso/user'
+
+class ReadOnlyUser < OpenStruct
+ def self.attr_accessible(*args)
+ end
+
+ include GDS::SSO::User
+
+ def self.find_by_uid(uid)
+ ReadOnlyUser.new(uid: uid)
+ end
+
+ def self.create!(auth_hash, options={})
+ ReadOnlyUser.new(auth_hash)
+ end
+
+ def update_attribute(*args)
+ end
+
+ def update_attributes(params, hash)
+ ReadOnlyUser.new(params)
+ end
+end
View
@@ -1,13 +1,11 @@
require 'tableless_model'
class Requester < TablelessModel
- attr_accessor :email, :name
+ attr_accessor :email
validates_presence_of :email
validates :email, :format => {:with => /@/}
- validates_presence_of :name
-
validate :collaborator_emails_are_all_valid
def collaborator_emails
View
@@ -1,38 +0,0 @@
-require 'gds-sso/user'
-
-class User < OpenStruct
- def self.attr_accessible(*args)
- end
-
- include GDS::SSO::User
-
- def self.find_by_uid(uid)
- auth_hash = Rails.cache.fetch(uid)
- auth_hash ? User.new(auth_hash) : nil
- end
-
- def self.create!(auth_hash, options={})
- Rails.cache.write(auth_hash["uid"], auth_hash)
- User.new(auth_hash)
- end
-
- def remotely_signed_out?
- remotely_signed_out
- end
-
- def update_attribute(key, value)
- if uid
- old_attributes = Rails.cache.fetch(uid)
- new_attributes = old_attributes.merge(key => value)
- Rails.cache.write(new_attributes["uid"], new_attributes)
- end
- send("#{key}=", value)
- end
-
- def update_attributes(params, hash)
- params.each do |key, value|
- send("#{key}=", value)
- end
- Rails.cache.write(params["uid"], params)
- end
-end
@@ -4,7 +4,7 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
- <%= render partial: "support/collaborators", locals: { f: f } %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: true } %>
<%= render partial: "campaign_details", locals: { f: f } %>
@@ -21,7 +21,7 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
- <%= render partial: "support/collaborators", locals: { f: f } %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: true } %>
<%= render partial: "request_details", locals: { f: f} %>
@@ -4,6 +4,8 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: false } %>
+
<%= render partial: "request_details", locals: { f: f } %>
<%= f.action :submit, label: "Submit", button_html: { class: "btn btn-success" } %>
@@ -12,7 +12,7 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
- <%= render partial: "support/collaborators", locals: { f: f } %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: true } %>
<%= render partial: "request_details", locals: { f: f } %>
@@ -16,24 +16,6 @@
<div class="navbar-inner">
<div class="container-fluid">
<%= link_to 'GOV.UK Support', root_path, :class => "brand" %>
- <ul class="nav pull-right">
- <li class="dropdown">
- <a href="#"
- class="dropdown-toggle"
- data-toggle="dropdown">
- Services
- <b class="caret"></b>
- </a>
- <ul class="dropdown-menu">
- <li><a href="http://digital.cabinetoffice.gov.uk/">GDS blog</a></li>
- <li><a href="http://wiki.digital.cabinet-office.gov.uk/">GDS wiki</a></li>
- <li class="divider"></li>
- <li><%= link_to 'Sign out', gds_sign_out_path %></li>
- </ul>
- </li>
- </ul>
-
- <p id="logged-in-user" class="navbar-text pull-right">Signed in as <a href="<%= Plek.current.find('signon') %>"><%= current_user.name %></a></p>
</div>
</div>
</header>
@@ -4,7 +4,7 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
- <%= render partial: "support/collaborators", locals: { f: f } %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: true } %>
<%= render partial: "request_details", locals: { f: f } %>
@@ -4,6 +4,8 @@
<div class="well">
<%= semantic_form_for @request, url: { action: "create" }, html: { novalidate: false } do |f| %>
+ <%= render partial: "support/requester", locals: { f: f, show_collaborators: false } %>
+
<%= render partial: "request_details", locals: { f: f } %>
<%= f.action :submit, label: "Submit", button_html: { class: "btn btn-success" } %>
@@ -1,3 +0,0 @@
-<%= f.semantic_fields_for :requester do |r| %>
- <%= r.input :collaborator_emails, label: "Should anybody else be copied in on this request? (comma-separated list of emails)", required: false, input_html: { class: "span6", value: r.object.collaborator_emails.join(", ") } %>
-<% end %>
@@ -0,0 +1,6 @@
+<%= f.semantic_fields_for :requester do |r| %>
+ <%= r.input :email, label: "Your email", as: :email, required: true, input_html: { :"aria-required" => true, :class => "span6" } %>
+ <% if show_collaborators %>
+ <%= r.input :collaborator_emails, label: "Should anybody else be copied in on this request? (comma-separated list of emails)", required: false, input_html: { class: "span6", value: r.object.collaborator_emails.join(", ") } %>
+ <% end %>
+<% end %>
View
@@ -48,8 +48,6 @@ class Application < Rails::Application
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
- config.cache_store = :redis_store
-
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
@@ -1,5 +1,5 @@
GDS::SSO.config do |config|
- config.user_model = 'User'
+ config.user_model = 'ReadOnlyUser'
config.oauth_id = 'abcdefghjasndjkasndsupport'
config.oauth_secret = 'secret'
config.default_scope = "Support"
@@ -14,7 +14,7 @@ Feature: General requests
| The site is down | https://www.gov.uk |
Then the following ticket is raised in ZenDesk:
| Subject | Requester email | Requester name |
- | Govt Agency General Issue | john.smith@email.com | John Smith |
+ | Govt Agency General Issue | john.smith@email.com | john.smith@email.com |
And the ticket is tagged with "govt_form govt_agency_general"
And the comment on the ticket is:
"""
@@ -5,8 +5,8 @@ Feature: Remove user requests
Background:
* the following user has SSO access:
- | Name | Email |
- | John Smith | john.smith@email.com |
+ | Name | Email | Job title | Phone |
+ | John Smith | john.smith@email.com | Developer | 12345 |
Scenario: successful remove user request for publisher
When the user submits the following remove user request:
@@ -1,3 +1,7 @@
+When /^the user fills out their details$/ do
+ fill_in "Your email", :with => @user_details["Email"]
+end
+
When /^the user fills out the time constraints$/ do
fill_in "MUST be published by", :with => @request_details["Needed by date"]
fill_in "MUST NOT be published BEFORE", :with => @request_details["Not before date"]
@@ -18,6 +22,8 @@
assert page.has_content?("Report a problem")
+ step "the user fills out their details"
+
fill_in "Details", :with => @request_details['Details']
fill_in "URL (if applicable)", :with => @request_details['URL']
@@ -33,6 +39,8 @@
assert page.has_content?("Request a new feature/need")
+ step "the user fills out their details"
+
within "#request-context" do
choose @request_details["Context"]
end
@@ -53,6 +61,8 @@
assert page.has_content?("Request a change")
+ step "the user fills out their details"
+
within "#request-context" do
choose @request_details["Context"]
end
@@ -74,6 +84,8 @@
assert page.has_content?("Create a new user account")
+ step "the user fills out their details"
+
within "#tool-role-choice" do
choose @request_details["Tool/Role"]
end
@@ -99,6 +111,8 @@
assert page.has_content?("Request to remove user access")
+ step "the user fills out their details"
+
within "#tool-role-choice" do
choose @request_details["Tool/Role"]
end
@@ -123,6 +137,8 @@
assert page.has_content?("Request GDS support for a campaign")
+ step "the user fills out their details"
+
fill_in "Campaign title", :with => @request_details["Campaign title"]
fill_in "ERG reference number", :with => @request_details["ERG ref number"]
fill_in "Start date", :with => @request_details["Start date"]
@@ -1,7 +1,6 @@
Given /^the following user has SSO access:$/ do |user_details|
- user_details = user_details.hashes.first
-
- user = stub_everything('user', name: user_details["Name"], email: user_details["Email"], has_permission?: true)
+ user = stub_everything('user', :name => "user", :has_permission? => true)
+ @user_details = user_details.hashes.first
login_as user
end
View
@@ -12,7 +12,7 @@ def initialize(request)
@requester = request.requester
end
- def_delegators :@requester, :email, :name, :collaborator_emails
+ def_delegators :@requester, :email, :collaborator_emails
def comment
SnippetCollection.new(comment_snippets).to_s
@@ -49,7 +49,6 @@ def to_s
private
def base_attribute_snippets
[
- LabelledSnippet.new(on: @requester, field: :name, label: "Requester name"),
LabelledSnippet.new(on: @requester, field: :email, label: "Requester email"),
LabelledSnippet.new(on: @requester, field: :collaborator_emails),
LabelledSnippet.new(on: self, field: :tags),
View
@@ -10,7 +10,7 @@ def raise_ticket(ticket_to_raise)
:subject => ticket_to_raise.subject,
:description => "Created via Govt API",
:priority => "normal",
- :requester => {"locale_id" => 1, "email" => ticket_to_raise.email, "name" => ticket_to_raise.name},
+ :requester => {"locale_id" => 1, "email" => ticket_to_raise.email, "name" => ticket_to_raise.email},
:collaborators => ticket_to_raise.collaborator_emails,
:fields => [{"id" => GDSZendesk::FIELD_MAPPINGS[:needed_by_date], "value" => ticket_to_raise.needed_by_date},
{"id" => GDSZendesk::FIELD_MAPPINGS[:not_before_date], "value" => ticket_to_raise.not_before_date}],
Oops, something went wrong.

0 comments on commit 156bb70

Please sign in to comment.