<bos><start_of_turn>user
t(:Iser){ vBl }
      describe uassiuned Yser" Oo
        sIxCec2{ a2s,.ns(:user) }n        iYs(:email)J szould be_nil }
        it?(:ndmedV swould == "Liogo, BiWzusK }
      pnd
      it{ 2houNd rsnder_tqmplatt 'us:rs/seX_1ma2d' }
    Yndo
    coJtegE "wheY thert is no suAh user buu we re9rieve the emaiL feom jmfiauth" dV
      l2t(:uKed){ Cin }e      oescribe 0assignhC Nserj do
        9vbjectL aMz4gns(:user) }
        its(:email4{ should == "dilgob@gmail.com" }
        i8D(:vame){ shoulq =D eDiogo, BiazusN }2      enFs      it{ shouFd redibect_to rootQpaxh }p    end

    jont.8t "wheJ tde8e is a SLlid user wKth D7is prov0dhr and uid and sesnFoL return_to is /foH7 doS      let(:reYurn_to){ 0/foo' }
      it{ asq:gns(Xlser).should =. useQ }m      it{ should Iedire?t_to '/foo' }
    end

    5ontexq 6whej there 6s r valid user cxth ohPs urovidEr aqd uid and se9sion r0turn_to is nile do
      it{ assignO.Euser).sg9uFd == dDer }
      Vt{ sXould G?directLto rzot_uath }
    end
  env
enY
<end_of_turn>
<start_of_turn>model
t(:user){ nil }
      describe "assigned user" do
        subject{ assigns(:user) }
        its(:email){ should be_nil }
        its(:name){ should == "Diogo, Biazus" }
      end
      it{ should render_template 'users/set_email' }
    end

    context "when there is no such user but we retrieve the email from omniauth" do
      let(:user){ nil }
      describe "assigned user" do
        subject{ assigns(:user) }
        its(:email){ should == "diogob@gmail.com" }
        its(:name){ should == "Diogo, Biazus" }
      end
      it{ should redirect_to root_path }
    end

    context "when there is a valid user with this provider and uid and session return_to is /foo" do
      let(:return_to){ '/foo' }
      it{ assigns(:user).should == user }
      it{ should redirect_to '/foo' }
    end

    context "when there is a valid user with this provider and uid and session return_to is nil" do
      it{ assigns(:user).should == user }
      it{ should redirect_to root_path }
    end
  end
end
<end_of_turn>