Welcome to mirror list, hosted at ThFree Co, Russian Federation.

photos_controller_spec.rb « controllers « spec - github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86d8d448c5fe0b5c892c4d99a7f8bfa5e8a9bffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#   Copyright (c) 2010, Diaspora Inc.  This file is
#   licensed under the Affero General Public License version 3 or later.  See
#   the COPYRIGHT file.

require 'spec_helper'

describe PhotosController do
  render_views
  before do
    @user = Factory.create(:user)
    @aspect = @user.aspect(:name => "lame-os")
    @album = @user.post :album, :to => @aspect.id, :name => 'things on fire'
    @fixture_filename = 'button.png'
    @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename)
    image = File.open(@fixture_name)
    #@photo = Photo.instantiate(
     #         :person => @user.person, :album => @album, :user_file => image)
    @photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id)
    sign_in :user, @user
  end

  describe '#create' do
  end

  describe "#update" do
    it "should update the caption of a photo" do
      put :update, :id => @photo.id, :photo => { :caption => "now with lasers!"}
      @photo.reload.caption.should == "now with lasers!"
    end
    
    it "doesn't overwrite random attributes" do
      new_user = Factory.create :user
      params = { :caption => "now with lasers!", :person_id => new_user.id}
      put :update, :id => @photo.id, :photo => params
      @photo.reload.person_id.should == @user.person.id
    end
  end
end