~cytrogen/masto-fe

ref: 91040da871dba71a6eb05cd7ae3ed8b9b255680c masto-fe/spec/lib/scope_transformer_spec.rb -rw-r--r-- 2.1 KiB
91040da8 — Claire Fix confusing behavior of mute button and volume slider in web UI (#26860) 2 years ago
                                                                                
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# frozen_string_literal: true

require 'rails_helper'

describe ScopeTransformer do
  describe '#apply' do
    subject { described_class.new.apply(ScopeParser.new.parse(input)) }

    shared_examples 'a scope' do |namespace, term, access|
      it 'parses the term' do
        expect(subject.term).to eq term
      end

      it 'parses the namespace' do
        expect(subject.namespace).to eq namespace
      end

      it 'parses the access' do
        expect(subject.access).to eq access
      end
    end

    context 'with scope "read"' do
      let(:input) { 'read' }

      it_behaves_like 'a scope', nil, 'all', 'read'
    end

    context 'with scope "write"' do
      let(:input) { 'write' }

      it_behaves_like 'a scope', nil, 'all', 'write'
    end

    context 'with scope "follow"' do
      let(:input) { 'follow' }

      it_behaves_like 'a scope', nil, 'follow', 'read/write'
    end

    context 'with scope "crypto"' do
      let(:input) { 'crypto' }

      it_behaves_like 'a scope', nil, 'crypto', 'read/write'
    end

    context 'with scope "push"' do
      let(:input) { 'push' }

      it_behaves_like 'a scope', nil, 'push', 'read/write'
    end

    context 'with scope "admin:read"' do
      let(:input) { 'admin:read' }

      it_behaves_like 'a scope', 'admin', 'all', 'read'
    end

    context 'with scope "admin:write"' do
      let(:input) { 'admin:write' }

      it_behaves_like 'a scope', 'admin', 'all', 'write'
    end

    context 'with scope "admin:read:accounts"' do
      let(:input) { 'admin:read:accounts' }

      it_behaves_like 'a scope', 'admin', 'accounts', 'read'
    end

    context 'with scope "admin:write:accounts"' do
      let(:input) { 'admin:write:accounts' }

      it_behaves_like 'a scope', 'admin', 'accounts', 'write'
    end

    context 'with scope "read:accounts"' do
      let(:input) { 'read:accounts' }

      it_behaves_like 'a scope', nil, 'accounts', 'read'
    end

    context 'with scope "write:accounts"' do
      let(:input) { 'write:accounts' }

      it_behaves_like 'a scope', nil, 'accounts', 'write'
    end
  end
end