<commit_before>require 'rails_helper'

describe UsersController do
  let!(:user) {FactoryGirl.create :user}
  let!(:attrubutes) {FactoryGirl.attributes_for :user}
  before do
    session[:id] = 1
  end
  describe "#show" do
    context "a valid user" do
      it "returns a 200" do
      get(:show, {id:  1})
        expect(response.status).to eq(200)
      end
    end
    context "an invalid user" do
      before do
        session[:id] = 2
      end
      it "redirects to the root path" do
      get(:show, {id:  1})
        expect(response.status).to eq(302)
      end
    end
  end
  describe "#update" do
    it "updates a user's password with valid params" do
      put :update, id: user.id,  old_password: <PASSWORD>,  user: { password: "<PASSWORD>" }, password_again: "<PASSWORD>"
      expect(user.reload.password).to eq('<PASSWORD>')
    end
    xit "does not update a user's password if the original passwor is incorrect" do
    end
    xit "does not update a user's password it the new password fields do not match" do
    end
  end
end<commit_msg>Tests update method. First test green, two pending<commit_after>require 'rails_helper'

describe UsersController do
  let!(:user) { FactoryGirl.create :user }
  let!(:attrubutes) { FactoryGirl.attributes_for :user }
  before do
    session[:id] = 1
  end
  describe "#show" do
    context "a valid user" do
      it "returns a 200" do
      get(:show, {id:  1})
        expect(response.status).to eq(200)
      end
    end
    context "an invalid user" do
      before do
        session[:id] = 2
      end
      it "redirects to the root path" do
      get(:show, {id:  1})
        expect(response.status).to eq(302)
      end
    end
  end
  describe "PUT #update" do
    let!(:pass) { "<PASSWORD>" }
    let!(:old_salt) { user.password_digest }
    it "updates a user's password with valid params" do
      put :update, id: user.id, old_password: <PASSWORD>, user: { password: <PASSWORD> }, password_again: <PASSWORD>
      expect(user.reload.password_digest).to_not eq(old_salt)
    end
    xit "does not update a user's password if the original password is incorrect" do
    end
    xit "does not update a user's password it the new password fields do not match" do
    end
  end
end
{'fraction_non_alphanumeric': 0.10439804531319413, 'fraction_numerical': 0.011550422034651266, 'mean_word_length': 2.784873949579832, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3941854', 'n_tokens_mistral': 740, 'n_tokens_neox': 699, 'n_words': 253}