blob: 8f4b6244725cd0ac078459b48ea4a5c4750cdd49 (
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
39
|
require "rails_helper"
describe My::AvatarsController do
let(:user) { create(:user) }
context "when logged in " do
before { http_login(user) }
describe "#create" do
context "when uploading a new avatar" do
let(:image) { Rack::Test::UploadedFile.new('spec/fixtures/images/gorilla.jpg', 'image/jpeg') }
before { post :create, params: { photo: { image: image } } }
it "saves the new avatar" do
user.reload
expect(user.avatar).to_not be_nil
expect(user.avatar.image).to_not be_blank
end
it "redirects to the avatar page" do
expect(response).to redirect_to(new_my_avatar_path)
end
it "displays a flash notice" do
expect(flash[:notice]).to_not be_nil
end
end
end
describe "#new" do
before { get :new, params: { id: user.id } }
it "displays the current avatar" do
expect(assigns(:avatar)).to_not be_nil
end
end
end
end
|