Remove email from User model and API
It was never actually used for anything except to enforce uniqueness, which should be done by the LMS.
This commit is contained in:
Родитель
78c8e6b80c
Коммит
1d5017641f
2
Rakefile
2
Rakefile
|
@ -34,7 +34,7 @@ task :environment do
|
|||
end
|
||||
|
||||
def create_test_user(id)
|
||||
User.create!(external_id: id, username: "user#{id}", email: "user#{id}@test.com")
|
||||
User.create!(external_id: id, username: "user#{id}")
|
||||
end
|
||||
|
||||
Dir.glob('lib/tasks/*.rake').each { |r| import r }
|
||||
|
|
|
@ -3,7 +3,6 @@ require 'new_relic/agent/method_tracer'
|
|||
post "#{APIPREFIX}/users" do
|
||||
user = User.new(external_id: params["id"])
|
||||
user.username = params["username"]
|
||||
user.email = params["email"]
|
||||
user.save
|
||||
if user.errors.any?
|
||||
error 400, user.errors.full_messages.to_json
|
||||
|
@ -67,7 +66,7 @@ end
|
|||
|
||||
put "#{APIPREFIX}/users/:user_id" do |user_id|
|
||||
user = User.find_or_create_by(external_id: user_id)
|
||||
user.update_attributes(params.slice(*%w[username email default_sort_key]))
|
||||
user.update_attributes(params.slice(*%w[username default_sort_key]))
|
||||
if user.errors.any?
|
||||
error 400, user.errors.full_messages.to_json
|
||||
else
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
def log_in
|
||||
visit "/"
|
||||
click_link "Log In"
|
||||
fill_in "email", with: "student@student.com"
|
||||
fill_in "password", with: "student"
|
||||
click_button "Access My Courses"
|
||||
wait_until { page.find('.dashboard') }
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace :benchmark do
|
|||
|
||||
x.report "create users" do
|
||||
(1..USERS).each do |user_id|
|
||||
data = { id: user_id, username: "user#{user_id}", email: "user#{user_id}@test.com" }
|
||||
data = { id: user_id, username: "user#{user_id}" }
|
||||
RestClient.post "#{PREFIX}/users", data
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,7 +7,6 @@ class User
|
|||
field :_id, type: String, default: -> { external_id }
|
||||
field :external_id, type: String
|
||||
field :username, type: String
|
||||
field :email, type: String
|
||||
field :default_sort_key, type: String, default: "date"
|
||||
|
||||
embeds_many :read_states
|
||||
|
@ -18,10 +17,8 @@ class User
|
|||
|
||||
validates_presence_of :external_id
|
||||
validates_presence_of :username
|
||||
validates_presence_of :email
|
||||
validates_uniqueness_of :external_id
|
||||
validates_uniqueness_of :username
|
||||
validates_uniqueness_of :email
|
||||
|
||||
index( {external_id: 1}, {unique: true, background: true} )
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
db.users.dropIndex({email: 1})
|
|
@ -0,0 +1 @@
|
|||
db.users.ensureIndex({email: 1}, {background: true})
|
|
@ -11,7 +11,7 @@ describe "app" do
|
|||
describe "POST /api/v1/notifications" do
|
||||
it "returns notifications by class and user" do
|
||||
start_time = Time.now
|
||||
user = User.create(:email => "test@example.com",:external_id => 1,:username => "example")
|
||||
user = User.create(:external_id => 1,:username => "example")
|
||||
commentable = Commentable.new("question_1")
|
||||
random_string = (0...8).map{ ('a'..'z').to_a[rand(26)] }.join
|
||||
thread = CommentThread.new(title: "Test title", body: "elephant otter", course_id: "1", commentable_id: commentable.id, comments_text_dummy: random_string)
|
||||
|
@ -42,7 +42,7 @@ describe "app" do
|
|||
|
||||
# first make a dummy thread and comment and a subscription
|
||||
commentable = Commentable.new("question_1")
|
||||
user = User.create(:email => "test@example.com",:external_id => 1,:username => "example")
|
||||
user = User.create(:external_id => 1,:username => "example")
|
||||
random_string = (0...8).map{ ('a'..'z').to_a[rand(26)] }.join
|
||||
|
||||
thread = CommentThread.new(title: "Test title", body: "elephant otter", course_id: "1", commentable_id: commentable.id, comments_text_dummy: random_string)
|
||||
|
@ -85,7 +85,7 @@ describe "app" do
|
|||
start_time = Date.today - 100.days
|
||||
|
||||
|
||||
user = User.create(:email => "test@example.com",:external_id => 1,:username => "example")
|
||||
user = User.create(:external_id => 1,:username => "example")
|
||||
|
||||
sleep 1
|
||||
|
||||
|
|
|
@ -11,18 +11,15 @@ describe "app" do
|
|||
end
|
||||
describe "POST /api/v1/users" do
|
||||
it "creates a user" do
|
||||
post "/api/v1/users", id: "100", username: "user100", email: "user100@test.com"
|
||||
post "/api/v1/users", id: "100", username: "user100"
|
||||
last_response.should be_ok
|
||||
user = User.find_by(external_id: "100")
|
||||
user.username.should == "user100"
|
||||
user.email.should == "user100@test.com"
|
||||
end
|
||||
it "returns error when id / username / email already exists" do
|
||||
post "/api/v1/users", id: "1", username: "user100", email: "user100@test.com"
|
||||
it "returns error when id / username already exists" do
|
||||
post "/api/v1/users", id: "1", username: "user100"
|
||||
last_response.status.should == 400
|
||||
post "/api/v1/users", id: "100", username: "user1", email: "user100@test.com"
|
||||
last_response.status.should == 400
|
||||
post "/api/v1/users", id: "100", username: "user100", email: "user1@test.com"
|
||||
post "/api/v1/users", id: "100", username: "user1"
|
||||
last_response.status.should == 400
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,8 +23,8 @@ require 'spec_helper'
|
|||
#what is the 'at' symbol doing there? @dementrock
|
||||
#"""
|
||||
# User.delete_all
|
||||
# User.create!(external_id: "1", username: "tom", email: "tom@test.com")
|
||||
# User.create!(external_id: "2", username: "pi314", email: "pi314@test.com")
|
||||
# User.create!(external_id: "1", username: "tom")
|
||||
# User.create!(external_id: "2", username: "pi314")
|
||||
# end
|
||||
#
|
||||
# describe "#get_marked_text(text)" do
|
||||
|
|
|
@ -52,7 +52,7 @@ def parse(text)
|
|||
end
|
||||
|
||||
def create_test_user(id)
|
||||
User.create!(external_id: id.to_s, username: "user#{id}", email: "user#{id}@test.com")
|
||||
User.create!(external_id: id.to_s, username: "user#{id}")
|
||||
end
|
||||
|
||||
def init_without_subscriptions
|
||||
|
|
Загрузка…
Ссылка в новой задаче