diff options
Diffstat (limited to 'spec/models/concerns/avatarable_spec.rb')
-rw-r--r-- | spec/models/concerns/avatarable_spec.rb | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/spec/models/concerns/avatarable_spec.rb b/spec/models/concerns/avatarable_spec.rb index 1ea7f2b9985..245625b80bd 100644 --- a/spec/models/concerns/avatarable_spec.rb +++ b/spec/models/concerns/avatarable_spec.rb @@ -1,43 +1,43 @@ -require 'spec_helper' +require "spec_helper" describe Avatarable do let(:project) { create(:project, :with_avatar) } let(:gitlab_host) { "https://gitlab.example.com" } let(:relative_url_root) { "/gitlab" } - let(:asset_host) { 'https://gitlab-assets.example.com' } + let(:asset_host) { "https://gitlab-assets.example.com" } before do stub_config_setting(base_url: gitlab_host) stub_config_setting(relative_url_root: relative_url_root) end - describe '#update' do + describe "#update" do let(:validator) { project._validators[:avatar].detect { |v| v.is_a?(FileSizeValidator) } } - context 'when avatar changed' do - it 'validates the file size' do + context "when avatar changed" do + it "validates the file size" do expect(validator).to receive(:validate_each).and_call_original - project.update(avatar: 'uploads/avatar.png') + project.update(avatar: "uploads/avatar.png") end end - context 'when avatar was not changed' do - it 'skips validation of file size' do + context "when avatar was not changed" do + it "skips validation of file size" do expect(validator).not_to receive(:validate_each) - project.update(name: 'Hello world') + project.update(name: "Hello world") end end end - describe '#avatar_path' do - context 'with caching enabled', :request_store do + describe "#avatar_path" do + context "with caching enabled", :request_store do let!(:avatar_path) { [relative_url_root, project.avatar.local_url].join } let!(:avatar_url) { [gitlab_host, relative_url_root, project.avatar.local_url].join } - it 'only calls local_url once' do + it "only calls local_url once" do expect(project.avatar).to receive(:local_url).once.and_call_original 2.times do @@ -45,21 +45,21 @@ describe Avatarable do end end - it 'calls local_url twice for path and URLs' do + it "calls local_url twice for path and URLs" do expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original expect(project.avatar_path(only_path: true)).to eq(avatar_path) expect(project.avatar_path(only_path: false)).to eq(avatar_url) end - it 'calls local_url twice for different sizes' do + it "calls local_url twice for different sizes" do expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original expect(project.avatar_path).to eq(avatar_path) expect(project.avatar_path(size: 40)).to eq(avatar_path + "?width=40") end - it 'handles unpersisted objects' do + it "handles unpersisted objects" do new_project = build(:project, :with_avatar) path = [relative_url_root, new_project.avatar.local_url].join expect(new_project.avatar).to receive(:local_url).exactly(2).times.and_call_original @@ -96,11 +96,11 @@ describe Avatarable do let(:avatar_path) { (avatar_path_prefix + [project.avatar.local_url]).join } - it 'returns the expected avatar path' do + it "returns the expected avatar path" do expect(project.avatar_path(only_path: only_path)).to eq(avatar_path) end - it 'returns the expected avatar path with width parameter' do + it "returns the expected avatar path with width parameter" do expect(project.avatar_path(only_path: only_path, size: 128)).to eq(avatar_path + "?width=128") end @@ -111,7 +111,7 @@ describe Avatarable do project.avatar.migrate!(ObjectStorage::Store::REMOTE) end - it 'returns the expected avatar path' do + it "returns the expected avatar path" do expect(project.avatar_url(only_path: only_path)).to eq(avatar_path) end end |