|
1 | 1 | RSpec.describe Taggable do
|
2 | 2 | let(:organization) { Fabricate(:organization) }
|
3 |
| - |
| 3 | + let(:tags) { %w(foo bar baz) } |
| 4 | + let(:more_tags) { %w(foo baz qux) } |
4 | 5 | let!(:offer) do
|
5 | 6 | Fabricate(
|
6 | 7 | :offer,
|
|
17 | 18 | end
|
18 | 19 |
|
19 | 20 | context "class methods and scopes" do
|
20 |
| - let(:tags) { %w(foo bar baz) } |
21 |
| - let(:more_tags) { %w(foo baz qux) } |
22 |
| - |
23 | 21 | it "tagged_with" do
|
24 | 22 | expect(Offer.tagged_with("bar")).to eq [offer]
|
25 | 23 | end
|
|
33 | 31 | expect(Offer.find_like_tag("Foo")).to eq ["foo"]
|
34 | 32 | expect(Offer.find_like_tag("none")).to eq []
|
35 | 33 | end
|
36 |
| - end |
37 | 34 |
|
38 |
| - describe '.alphabetical_grouped_tags' do |
39 |
| - let(:tags) { %w(foo bar baz Boo) } |
40 |
| - let(:more_tags) { %w(foo baz qux) } |
| 35 | + describe '.alphabetical_grouped_tags' do |
| 36 | + let(:tags) { %w(foo bar baz Boo) } |
| 37 | + let(:more_tags) { %w(foo baz qux) } |
41 | 38 |
|
42 |
| - it 'sorts them by alphabetical order case insensitive' do |
43 |
| - expect(Offer.alphabetical_grouped_tags).to eq({ |
44 |
| - 'B' => [['bar', 1], ['baz', 2], ['Boo', 1]], |
45 |
| - 'F' => [['foo', 2]], |
46 |
| - 'Q' => [['qux', 1]] |
47 |
| - }) |
| 39 | + it 'sorts them by alphabetical order case insensitive' do |
| 40 | + expect(Offer.alphabetical_grouped_tags).to eq({ |
| 41 | + 'B' => [['bar', 1], ['baz', 2], ['Boo', 1]], |
| 42 | + 'F' => [['foo', 2]], |
| 43 | + 'Q' => [['qux', 1]] |
| 44 | + }) |
| 45 | + end |
48 | 46 | end
|
49 | 47 | end
|
| 48 | + |
| 49 | + it "#tag_list= writter accepts string and array" do |
| 50 | + offer = Offer.new |
| 51 | + |
| 52 | + offer.tag_list = ["a", "b"] |
| 53 | + expect(offer.tag_list).to eq "a, b" |
| 54 | + |
| 55 | + offer.tag_list = "c, d" |
| 56 | + expect(offer.tag_list).to eq "c, d" |
| 57 | + end |
50 | 58 | end
|
0 commit comments