<commit_before>require "spec_helper"

describe UsersController do
  
  let(:user) { create :user }

  context "anonymous user" do
  
    describe "edit user" do
      it "has a 302 status code if user logged out" do
        user = build(:user)
        get :edit, uid: user.username
        expect(response.status).to eq(302)
      end
    end
    
  end
  
  context "authenticated user" do
  
    before do
      sign_in user
    end
  
    describe "edit user" do
      it "has a 200 status code if user logged in" do
        user = build(:user)
        get :edit, uid: user.username
        expect(response.status).to eq(200)
      end
    end
    
    describe "update user" do
      it "has a 302 status code if user logged in" do
        user = build(:user)
        post :update, uid: user.username, public_key: '-----END PGP PUBLIC KEY BLOCK-----'
        expect(response.status).to eq(302)
        flash[:notice].should match('Public key was successfully updated.')
      end
    end
    
  end

end<commit_msg>added spec for user edit page<commit_after>require "spec_helper"

describe UsersController do
  
  let(:user) { create :user }

  context "anonymous user" do
  
    describe "edit user" do
      it "has a 302 status code if user logged out" do
        user = build(:user)
        get :edit, uid: user.username, context: "publickey"
        expect(response.status).to eq(302)
      end
    end
    
    describe "edit user" do
      it "has a 302 status code if user logged out" do
        user = build(:user)
        get :edit, uid: user.username, context: "layout"
        expect(response.status).to eq(302)
      end
    end
    
  end
  
  context "authenticated user" do
  
    before do
      sign_in user
    end
  
    describe "edit user" do
      it "has a 200 status code if user logged in" do
        user = build(:user)
        get :edit, uid: user.username, context: "publickey"
        expect(response.status).to eq(200)
      end
    end
    
    describe "edit user" do
      it "has a 200 status code if user logged in" do
        user = build(:user)
        get :edit, uid: user.username, context: "layout"
        expect(response.status).to eq(200)
      end
    end
    
    describe "update user" do
      it "has a 302 status code if user logged in" do
        user = build(:user)
        post :update, uid: user.username, public_key: '-----END PGP PUBLIC KEY BLOCK-----'
        expect(response.status).to eq(302)
        flash[:notice].should match('Public key was successfully updated.')
      end
    end
    
  end

end
{'fraction_non_alphanumeric': 0.09200779727095516, 'fraction_numerical': 0.01871345029239766, 'mean_word_length': 2.069377990430622, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2389086', 'n_tokens_mistral': 812, 'n_tokens_neox': 759, 'n_words': 284}