|
3 | 3 | RSpec.describe Hyrax::CollectionPresenter do |
4 | 4 | let(:user) { FactoryBot.create :user } |
5 | 5 |
|
6 | | - let(:user_key) { 'a_user_key' } |
7 | | - let(:attributes) do {} end |
8 | | - |
| 6 | + let(:attributes) do |
| 7 | + { "bytes_lts" => '123' } |
| 8 | + end |
9 | 9 | let(:solr_document) { SolrDocument.new(attributes) } |
10 | 10 | let(:current_ability) { instance_double(Ability, current_user: user ) } |
11 | 11 | let(:request) { double(host: 'example.org', base_url: 'http://example.org') } |
|
17 | 17 | it { is_expected.to delegate_method(:collection?).to(:solr_document) } |
18 | 18 | it { is_expected.to delegate_method(:representative_id).to(:solr_document) } |
19 | 19 | it { is_expected.to delegate_method(:to_s).to(:solr_document) } |
| 20 | + |
| 21 | + it { is_expected.to delegate_method(:title).to(:solr_document) } |
| 22 | + it { is_expected.to delegate_method(:description).to(:solr_document) } |
| 23 | + it { is_expected.to delegate_method(:creator).to(:solr_document) } |
| 24 | + it { is_expected.to delegate_method(:contributor).to(:solr_document) } |
| 25 | + it { is_expected.to delegate_method(:subject).to(:solr_document) } |
| 26 | + it { is_expected.to delegate_method(:publisher).to(:solr_document) } |
| 27 | + it { is_expected.to delegate_method(:keyword).to(:solr_document) } |
| 28 | + it { is_expected.to delegate_method(:contributor).to(:solr_document) } |
| 29 | + it { is_expected.to delegate_method(:language).to(:solr_document) } |
| 30 | + it { is_expected.to delegate_method(:embargo_release_date).to(:solr_document) } |
| 31 | + it { is_expected.to delegate_method(:lease_expiration_date).to(:solr_document) } |
| 32 | + it { is_expected.to delegate_method(:license).to(:solr_document) } |
| 33 | + it { is_expected.to delegate_method(:date_created).to(:solr_document) } |
| 34 | + it { is_expected.to delegate_method(:resource_type).to(:solr_document) } |
| 35 | + it { is_expected.to delegate_method(:based_near).to(:solr_document) } |
| 36 | + it { is_expected.to delegate_method(:related_url).to(:solr_document) } |
| 37 | + it { is_expected.to delegate_method(:identifier).to(:solr_document) } |
| 38 | + it { is_expected.to delegate_method(:thumbnail_path).to(:solr_document) } |
| 39 | + it { is_expected.to delegate_method(:title_or_label).to(:solr_document) } |
| 40 | + it { is_expected.to delegate_method(:collection_type_gid).to(:solr_document) } |
| 41 | + it { is_expected.to delegate_method(:create_date).to(:solr_document) } |
| 42 | + it { is_expected.to delegate_method(:modified_date).to(:solr_document) } |
| 43 | + it { is_expected.to delegate_method(:visibility).to(:solr_document) } |
| 44 | + it { is_expected.to delegate_method(:edit_groups).to(:solr_document) } |
| 45 | + it { is_expected.to delegate_method(:edit_people).to(:solr_document) } |
| 46 | + |
| 47 | + describe "#size" do |
| 48 | + it "returns bytes as descriptive string" do |
| 49 | + expect(subject.size).to eq "123 Bytes" |
| 50 | + end |
| 51 | + end |
| 52 | + |
| 53 | + describe "#collection_type_badge" do |
| 54 | + it "returns collection_type.title" do |
| 55 | + |
| 56 | + allow(subject).to receive(:collection_type).and_return( double(title: 'Example of Grandiosity') ) |
| 57 | + expect(subject.collection_type_badge).to eq 'Example of Grandiosity' |
| 58 | + end |
| 59 | + end |
| 60 | + |
| 61 | + describe "#total_parent_collections" do |
| 62 | + it "returns parent_collections response numFound" do |
| 63 | + |
| 64 | + allow(subject).to receive(:parent_collections).and_return( double( response: {"numFound" => 7} ) ) |
| 65 | + expect(subject.total_parent_collections).to eq 7 |
| 66 | + end |
| 67 | + end |
| 68 | + |
| 69 | + describe "#parent_collection_count" do |
| 70 | + it "returns parent_collections documents size" do |
| 71 | + |
| 72 | + allow(subject).to receive(:parent_collections).and_return( double(documents: ['1', '2', '3', '4', '5']) ) |
| 73 | + expect(subject.parent_collection_count).to eq 5 |
| 74 | + end |
| 75 | + end |
| 76 | + |
| 77 | + |
| 78 | + |
| 79 | + describe "#create_work_presenter" do |
| 80 | + it "returns SelectTypeListPresenter" do |
| 81 | + expect(subject.create_work_presenter).to be_kind_of Hyrax::SelectTypeListPresenter |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + describe "#draw_select_work_modal?" do |
| 86 | + |
| 87 | + it "returns true" do |
| 88 | + allow(subject).to receive(:create_many_work_types?).and_return(true) |
| 89 | + expect(subject.draw_select_work_modal?).to eq true |
| 90 | + end |
| 91 | + |
| 92 | + it "returns false" do |
| 93 | + allow(subject).to receive(:create_many_work_types?).and_return(false) |
| 94 | + expect(subject.draw_select_work_modal?).to eq false |
| 95 | + end |
| 96 | + end |
| 97 | + |
| 98 | + describe "#first_work_type" do |
| 99 | + it "returns first string in list" do |
| 100 | + |
| 101 | + allow(subject.create_work_presenter).to receive(:authorized_models).and_return(["Alpha", "Beta"]) |
| 102 | + expect(subject.first_work_type).to eq "Alpha" |
| 103 | + end |
| 104 | + end |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
20 | 109 | end |
0 commit comments