|
15 | 15 | db_triggers.grep(/bob_count \+ 1/).size.should eql(1) |
16 | 16 | end |
17 | 17 |
|
| 18 | + shared_examples_for 'filterable' do |
| 19 | + it 'should take in consideration active record schema dumper ignore_tables option with regexp' do |
| 20 | + ActiveRecord::SchemaDumper.ignore_tables = [/users/] |
| 21 | + |
| 22 | + dump_schema.should_not match(/create_trigger/) |
| 23 | + end |
| 24 | + |
| 25 | + it 'should take in consideration active record schema dumper ignore_tables option with string' do |
| 26 | + ActiveRecord::SchemaDumper.ignore_tables = ['users'] |
| 27 | + |
| 28 | + dump_schema.should_not match(/create_trigger/) |
| 29 | + end |
| 30 | + |
| 31 | + it 'should take in consideration active record schema dumper ignore_tables option with partial string' do |
| 32 | + ActiveRecord::SchemaDumper.ignore_tables = ['user'] |
| 33 | + |
| 34 | + dump_schema.should match(/create_trigger/) |
| 35 | + end |
| 36 | + |
| 37 | + it 'should ignore configured ignore_tables option with regexp' do |
| 38 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_tables).and_return([/users/]) |
| 39 | + |
| 40 | + dump_schema.should_not match(/create_trigger/) |
| 41 | + end |
| 42 | + |
| 43 | + it 'should ignore configured ignore_tables option with string' do |
| 44 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_tables).and_return(['users']) |
| 45 | + |
| 46 | + dump_schema.should_not match(/create_trigger/) |
| 47 | + end |
| 48 | + |
| 49 | + it 'should not ignore configured ignore_tables option with partial string' do |
| 50 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_tables).and_return(['user']) |
| 51 | + |
| 52 | + dump_schema.should match(/create_trigger/) |
| 53 | + end |
| 54 | + |
| 55 | + it 'should ignore configured ignore_triggers option with regexp' do |
| 56 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_triggers).and_return([/bob/]) |
| 57 | + |
| 58 | + dump_schema.should_not match(/trigger.+bob/i) |
| 59 | + end |
| 60 | + |
| 61 | + it 'should ignore configured ignore_triggers option with string' do |
| 62 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_triggers).and_return(['users_after_insert_row_when_new_name_bob__tr']) |
| 63 | + |
| 64 | + dump_schema.should_not match(/trigger.+bob/i) |
| 65 | + end |
| 66 | + |
| 67 | + it 'should not ignore configured ignore_triggers option with partial string' do |
| 68 | + HairTrigger::SchemaDumper::Configuration.stub(:ignore_triggers).and_return(['users_after_insert_row_when_new_name_bob']) |
| 69 | + |
| 70 | + dump_schema.should match(/trigger.+bob/i) |
| 71 | + end |
| 72 | + |
| 73 | + it 'should allow configured allow_tables option with regexp' do |
| 74 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_tables).and_return([/users/]) |
| 75 | + |
| 76 | + dump_schema.should match(/create_trigger/) |
| 77 | + end |
| 78 | + |
| 79 | + it 'should allow configured allow_tables option with string' do |
| 80 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_tables).and_return(['users']) |
| 81 | + |
| 82 | + dump_schema.should match(/create_trigger/) |
| 83 | + end |
| 84 | + |
| 85 | + it 'should not allow configured allow_tables option with partial string' do |
| 86 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_tables).and_return(['user']) |
| 87 | + |
| 88 | + dump_schema.should_not match(/create_trigger/) |
| 89 | + end |
| 90 | + |
| 91 | + it 'should allow configured allow_triggers option with regexp' do |
| 92 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_triggers).and_return([/bob/]) |
| 93 | + |
| 94 | + dump_schema.should match(/trigger.+bob/i) |
| 95 | + end |
| 96 | + |
| 97 | + it 'should allow configured allow_triggers option with string' do |
| 98 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_triggers).and_return(['users_after_insert_row_when_new_name_bob__tr']) |
| 99 | + |
| 100 | + dump_schema.should match(/trigger.+bob/i) |
| 101 | + end |
| 102 | + |
| 103 | + it 'should not allow configured allow_triggers option with partial string' do |
| 104 | + HairTrigger::SchemaDumper::Configuration.stub(:allow_triggers).and_return(['users_after_insert_row_when_new_name_bob']) |
| 105 | + |
| 106 | + dump_schema.should_not match(/trigger.+bob/i) |
| 107 | + end |
| 108 | + end |
| 109 | + |
18 | 110 | context "without schema.rb" do |
19 | 111 | it "should work" do |
20 | 112 | schema_rb = dump_schema |
|
45 | 137 | schema_rb.should_not match(/bob_count \+ 2/) |
46 | 138 | end |
47 | 139 |
|
48 | | - it 'should take in consideration active record schema dumper ignore_tables option with regexp' do |
49 | | - ActiveRecord::SchemaDumper.ignore_tables = [/users/] |
50 | | - |
51 | | - dump_schema.should_not match(/create_trigger/) |
52 | | - end |
53 | | - |
54 | | - it 'should take in consideration active record schema dumper ignore_tables option with string' do |
55 | | - ActiveRecord::SchemaDumper.ignore_tables = ['users'] |
56 | | - |
57 | | - dump_schema.should_not match(/create_trigger/) |
58 | | - end |
59 | | - |
60 | | - it 'should take in consideration active record schema dumper ignore_tables option with partial string' do |
61 | | - ActiveRecord::SchemaDumper.ignore_tables = ['user'] |
62 | | - |
63 | | - dump_schema.should match(/create_trigger/) |
64 | | - end |
65 | | - |
66 | | - |
| 140 | + it_should_behave_like 'filterable' |
67 | 141 | end |
68 | 142 |
|
69 | 143 | context "with schema.rb" do |
|
100 | 174 | schema_rb.should_not match(/bob_count \+ 2/) |
101 | 175 | end |
102 | 176 |
|
103 | | - it 'should take in consideration active record schema dumper ignore_tables option with regexp' do |
104 | | - ActiveRecord::SchemaDumper.ignore_tables = [/users/] |
105 | | - |
106 | | - dump_schema.should_not match(/create_trigger/) |
107 | | - end |
108 | | - |
109 | | - it 'should take in consideration active record schema dumper ignore_tables option with string' do |
110 | | - ActiveRecord::SchemaDumper.ignore_tables = ['users'] |
111 | | - |
112 | | - dump_schema.should_not match(/create_trigger/) |
113 | | - end |
114 | | - |
115 | | - it 'should take in consideration active record schema dumper ignore_tables option with partial string' do |
116 | | - ActiveRecord::SchemaDumper.ignore_tables = ['user'] |
117 | | - |
118 | | - dump_schema.should match(/create_trigger/) |
119 | | - end |
120 | | - |
| 177 | + it_should_behave_like 'filterable' |
121 | 178 | end |
122 | 179 |
|
123 | 180 | end |
|
0 commit comments