Fix all the errors to get our tests green on Rails 5.1.

This commit is contained in:
Guo Xiang Tan
2017-08-31 12:06:56 +08:00
parent 898ee93547
commit 77d4c4d8dc
989 changed files with 5114 additions and 3117 deletions

View File

@ -32,7 +32,7 @@ RSpec.describe UsersController do
end
it "should be able to update a user" do
put "/u/#{user.username}.json", name: 'test.test'
put "/u/#{user.username}.json", params: { name: 'test.test' }
expect(response).to be_success
expect(user.reload.name).to eq('test.test')
@ -44,11 +44,45 @@ RSpec.describe UsersController do
end
it "should be able to update a user" do
put "/u/#{user.username}.json", name: 'testing123'
put "/u/#{user.username}.json", params: { name: 'testing123' }
expect(response).to be_success
expect(user.reload.name).to eq('testing123')
end
end
end
describe "#account_created" do
it "returns a message when no session is present" do
get "/u/account-created"
expect(response).to be_success
body = response.body
expect(body).to match(I18n.t('activation.missing_session'))
end
it "redirects when the user is logged in" do
sign_in(Fabricate(:user))
get "/u/account-created"
expect(response).to redirect_to("/")
end
context "when the user account is created" do
include ApplicationHelper
it "returns the message when set in the session" do
user = create_user
get "/u/account-created"
expect(response).to be_success
expect(response.body).to include(
"{\"message\":\"#{I18n.t("login.activate_email", email: user.email).gsub!("</", "<\\/")}\",\"show_controls\":true,\"username\":\"#{user.username}\",\"email\":\"#{user.email}\"}"
)
end
end
end
end