rwc9u-activerecord-oracle_enhanced-adapter 1.1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +89 -0
- data/License.txt +20 -0
- data/Manifest.txt +23 -0
- data/README.txt +51 -0
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +5 -0
- data/lib/active_record/connection_adapters/oracle_enhanced.rake +44 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +1137 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_cpk.rb +21 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +39 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_procedures.rb +110 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_reserved_words.rb +126 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_tasks.rb +11 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +11 -0
- data/oracle-enhanced.gemspec +35 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +535 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +32 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +826 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +85 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +21 -0
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +272 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +42 -0
- metadata +88 -0
| @@ -0,0 +1,85 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../../spec_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            if ActiveRecord::Base.instance_methods.include?('changed?')
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              describe "OracleEnhancedAdapter dirty object tracking" do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                before(:all) do
         | 
| 8 | 
            +
                  ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced",
         | 
| 9 | 
            +
                                                          :database => "xe",
         | 
| 10 | 
            +
                                                          :username => "hr",
         | 
| 11 | 
            +
                                                          :password => "hr")
         | 
| 12 | 
            +
                  @conn = ActiveRecord::Base.connection
         | 
| 13 | 
            +
                  @conn.execute <<-SQL
         | 
| 14 | 
            +
                    CREATE TABLE test_employees (
         | 
| 15 | 
            +
                      id            NUMBER,
         | 
| 16 | 
            +
                      first_name    VARCHAR2(20),
         | 
| 17 | 
            +
                      last_name     VARCHAR2(25),
         | 
| 18 | 
            +
                      job_id        NUMBER(6,0),
         | 
| 19 | 
            +
                      salary        NUMBER(8,2),
         | 
| 20 | 
            +
                      comments      CLOB,
         | 
| 21 | 
            +
                      hire_date     DATE
         | 
| 22 | 
            +
                    )
         | 
| 23 | 
            +
                  SQL
         | 
| 24 | 
            +
                  @conn.execute <<-SQL
         | 
| 25 | 
            +
                    CREATE SEQUENCE test_employees_seq  MINVALUE 1
         | 
| 26 | 
            +
                      INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
         | 
| 27 | 
            +
                  SQL
         | 
| 28 | 
            +
                  class TestEmployee < ActiveRecord::Base
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
                after(:all) do
         | 
| 33 | 
            +
                  Object.send(:remove_const, "TestEmployee")
         | 
| 34 | 
            +
                  @conn.execute "DROP TABLE test_employees"
         | 
| 35 | 
            +
                  @conn.execute "DROP SEQUENCE test_employees_seq"
         | 
| 36 | 
            +
                end  
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                it "should not mark empty string (stored as NULL) as changed when reassigning it" do
         | 
| 39 | 
            +
                  @employee = TestEmployee.create!(:first_name => '')
         | 
| 40 | 
            +
                  @employee.first_name = ''
         | 
| 41 | 
            +
                  @employee.should_not be_changed
         | 
| 42 | 
            +
                  @employee.reload
         | 
| 43 | 
            +
                  @employee.first_name = ''
         | 
| 44 | 
            +
                  @employee.should_not be_changed
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                it "should not mark empty integer (stored as NULL) as changed when reassigning it" do
         | 
| 48 | 
            +
                  @employee = TestEmployee.create!(:job_id => '')
         | 
| 49 | 
            +
                  @employee.job_id = ''
         | 
| 50 | 
            +
                  @employee.should_not be_changed
         | 
| 51 | 
            +
                  @employee.reload
         | 
| 52 | 
            +
                  @employee.job_id = ''
         | 
| 53 | 
            +
                  @employee.should_not be_changed
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                it "should not mark empty decimal (stored as NULL) as changed when reassigning it" do
         | 
| 57 | 
            +
                  @employee = TestEmployee.create!(:salary => '')
         | 
| 58 | 
            +
                  @employee.salary = ''
         | 
| 59 | 
            +
                  @employee.should_not be_changed
         | 
| 60 | 
            +
                  @employee.reload
         | 
| 61 | 
            +
                  @employee.salary = ''
         | 
| 62 | 
            +
                  @employee.should_not be_changed
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                it "should not mark empty text (stored as NULL) as changed when reassigning it" do
         | 
| 66 | 
            +
                  @employee = TestEmployee.create!(:comments => '')
         | 
| 67 | 
            +
                  @employee.comments = ''
         | 
| 68 | 
            +
                  @employee.should_not be_changed
         | 
| 69 | 
            +
                  @employee.reload
         | 
| 70 | 
            +
                  @employee.comments = ''
         | 
| 71 | 
            +
                  @employee.should_not be_changed
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                it "should not mark empty date (stored as NULL) as changed when reassigning it" do
         | 
| 75 | 
            +
                  @employee = TestEmployee.create!(:hire_date => '')
         | 
| 76 | 
            +
                  @employee.hire_date = ''
         | 
| 77 | 
            +
                  @employee.should_not be_changed
         | 
| 78 | 
            +
                  @employee.reload
         | 
| 79 | 
            +
                  @employee.hire_date = ''
         | 
| 80 | 
            +
                  @employee.should_not be_changed
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../../spec_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
             | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe "OracleEnhancedAdapter emulate OracleAdapter" do
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              before(:all) do
         | 
| 8 | 
            +
                ActiveRecord::ConnectionAdapters.send(:remove_const, :OracleAdapter)
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              it "should be an OracleAdapter" do
         | 
| 12 | 
            +
                @conn = ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced",
         | 
| 13 | 
            +
                                                        :database => "xe",
         | 
| 14 | 
            +
                                                        :username => "hr",
         | 
| 15 | 
            +
                                                        :password => "hr",
         | 
| 16 | 
            +
                                                        :emulate_oracle_adapter => true)
         | 
| 17 | 
            +
                ActiveRecord::Base.connection.should_not be_nil
         | 
| 18 | 
            +
                ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::OracleAdapter).should be_true
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,272 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/../../spec_helper.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "OracleEnhancedAdapter custom methods for create, update and destroy" do
         | 
| 4 | 
            +
              include LoggerSpecHelper
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              before(:all) do
         | 
| 7 | 
            +
                ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced",
         | 
| 8 | 
            +
                                                        :database => "xe",
         | 
| 9 | 
            +
                                                        :username => "hr",
         | 
| 10 | 
            +
                                                        :password => "hr")
         | 
| 11 | 
            +
                @conn = ActiveRecord::Base.connection
         | 
| 12 | 
            +
                plsql.connection = @conn.raw_connection
         | 
| 13 | 
            +
                @conn.execute("DROP TABLE test_employees") rescue nil
         | 
| 14 | 
            +
                @conn.execute <<-SQL
         | 
| 15 | 
            +
                  CREATE TABLE test_employees (
         | 
| 16 | 
            +
                    employee_id   NUMBER(6,0),
         | 
| 17 | 
            +
                    first_name    VARCHAR2(20),
         | 
| 18 | 
            +
                    last_name     VARCHAR2(25),
         | 
| 19 | 
            +
                    hire_date     DATE,
         | 
| 20 | 
            +
                    salary        NUMBER(8,2),
         | 
| 21 | 
            +
                    description   CLOB,
         | 
| 22 | 
            +
                    version       NUMBER(15,0),
         | 
| 23 | 
            +
                    create_time   DATE,
         | 
| 24 | 
            +
                    update_time   DATE
         | 
| 25 | 
            +
                  )
         | 
| 26 | 
            +
                SQL
         | 
| 27 | 
            +
                @conn.execute("DROP SEQUENCE test_employees_s") rescue nil
         | 
| 28 | 
            +
                @conn.execute <<-SQL
         | 
| 29 | 
            +
                  CREATE SEQUENCE test_employees_s  MINVALUE 1
         | 
| 30 | 
            +
                    INCREMENT BY 1 CACHE 20 NOORDER NOCYCLE
         | 
| 31 | 
            +
                SQL
         | 
| 32 | 
            +
                @conn.execute <<-SQL
         | 
| 33 | 
            +
                  CREATE OR REPLACE PACKAGE test_employees_pkg IS
         | 
| 34 | 
            +
                    PROCEDURE create_employee(
         | 
| 35 | 
            +
                        p_first_name    VARCHAR2,
         | 
| 36 | 
            +
                        p_last_name     VARCHAR2,
         | 
| 37 | 
            +
                        p_hire_date     DATE,
         | 
| 38 | 
            +
                        p_salary        NUMBER,
         | 
| 39 | 
            +
                        p_description   VARCHAR2,
         | 
| 40 | 
            +
                        p_employee_id   OUT NUMBER);
         | 
| 41 | 
            +
                    PROCEDURE update_employee(
         | 
| 42 | 
            +
                        p_employee_id   NUMBER,
         | 
| 43 | 
            +
                        p_first_name    VARCHAR2,
         | 
| 44 | 
            +
                        p_last_name     VARCHAR2,
         | 
| 45 | 
            +
                        p_hire_date     DATE,
         | 
| 46 | 
            +
                        p_salary        NUMBER,
         | 
| 47 | 
            +
                        p_description   VARCHAR2);
         | 
| 48 | 
            +
                    PROCEDURE delete_employee(
         | 
| 49 | 
            +
                        p_employee_id   NUMBER);
         | 
| 50 | 
            +
                  END;
         | 
| 51 | 
            +
                SQL
         | 
| 52 | 
            +
                @conn.execute <<-SQL
         | 
| 53 | 
            +
                  CREATE OR REPLACE PACKAGE BODY test_employees_pkg IS
         | 
| 54 | 
            +
                    PROCEDURE create_employee(
         | 
| 55 | 
            +
                        p_first_name    VARCHAR2,
         | 
| 56 | 
            +
                        p_last_name     VARCHAR2,
         | 
| 57 | 
            +
                        p_hire_date     DATE,
         | 
| 58 | 
            +
                        p_salary        NUMBER,
         | 
| 59 | 
            +
                        p_description   VARCHAR2,
         | 
| 60 | 
            +
                        p_employee_id   OUT NUMBER)
         | 
| 61 | 
            +
                    IS
         | 
| 62 | 
            +
                    BEGIN
         | 
| 63 | 
            +
                      SELECT test_employees_s.NEXTVAL INTO p_employee_id FROM dual;
         | 
| 64 | 
            +
                      INSERT INTO test_employees (employee_id, first_name, last_name, hire_date, salary, description,
         | 
| 65 | 
            +
                                                  version, create_time, update_time)
         | 
| 66 | 
            +
                      VALUES (p_employee_id, p_first_name, p_last_name, p_hire_date, p_salary, p_description,
         | 
| 67 | 
            +
                                                  1, SYSDATE, SYSDATE);
         | 
| 68 | 
            +
                    END create_employee;
         | 
| 69 | 
            +
                    
         | 
| 70 | 
            +
                    PROCEDURE update_employee(
         | 
| 71 | 
            +
                        p_employee_id   NUMBER,
         | 
| 72 | 
            +
                        p_first_name    VARCHAR2,
         | 
| 73 | 
            +
                        p_last_name     VARCHAR2,
         | 
| 74 | 
            +
                        p_hire_date     DATE,
         | 
| 75 | 
            +
                        p_salary        NUMBER,
         | 
| 76 | 
            +
                        p_description   VARCHAR2)
         | 
| 77 | 
            +
                    IS
         | 
| 78 | 
            +
                        v_version       NUMBER;
         | 
| 79 | 
            +
                    BEGIN
         | 
| 80 | 
            +
                      SELECT version INTO v_version FROM test_employees WHERE employee_id = p_employee_id FOR UPDATE;
         | 
| 81 | 
            +
                      UPDATE test_employees
         | 
| 82 | 
            +
                      SET employee_id = p_employee_id, first_name = p_first_name, last_name = p_last_name,
         | 
| 83 | 
            +
                          hire_date = p_hire_date, salary = p_salary, description = p_description,
         | 
| 84 | 
            +
                          version = v_version + 1, update_time = SYSDATE;
         | 
| 85 | 
            +
                    END update_employee;
         | 
| 86 | 
            +
                    
         | 
| 87 | 
            +
                    PROCEDURE delete_employee(
         | 
| 88 | 
            +
                        p_employee_id   NUMBER)
         | 
| 89 | 
            +
                    IS
         | 
| 90 | 
            +
                    BEGIN
         | 
| 91 | 
            +
                      DELETE FROM test_employees WHERE employee_id = p_employee_id;
         | 
| 92 | 
            +
                    END delete_employee;
         | 
| 93 | 
            +
                  END;
         | 
| 94 | 
            +
                SQL
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                class TestEmployee < ActiveRecord::Base
         | 
| 99 | 
            +
                  set_primary_key :employee_id
         | 
| 100 | 
            +
                  
         | 
| 101 | 
            +
                  validates_presence_of :first_name, :last_name, :hire_date
         | 
| 102 | 
            +
                  
         | 
| 103 | 
            +
                  # should return ID of new record
         | 
| 104 | 
            +
                  set_create_method do
         | 
| 105 | 
            +
                    plsql.test_employees_pkg.create_employee(
         | 
| 106 | 
            +
                      :p_first_name => first_name,
         | 
| 107 | 
            +
                      :p_last_name => last_name,
         | 
| 108 | 
            +
                      :p_hire_date => hire_date,
         | 
| 109 | 
            +
                      :p_salary => salary,
         | 
| 110 | 
            +
                      :p_description => "#{first_name} #{last_name}",
         | 
| 111 | 
            +
                      :p_employee_id => nil
         | 
| 112 | 
            +
                    )[:p_employee_id]
         | 
| 113 | 
            +
                  end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  # return value is ignored
         | 
| 116 | 
            +
                  set_update_method do
         | 
| 117 | 
            +
                    plsql.test_employees_pkg.update_employee(
         | 
| 118 | 
            +
                      :p_employee_id => id,
         | 
| 119 | 
            +
                      :p_first_name => first_name,
         | 
| 120 | 
            +
                      :p_last_name => last_name,
         | 
| 121 | 
            +
                      :p_hire_date => hire_date,
         | 
| 122 | 
            +
                      :p_salary => salary,
         | 
| 123 | 
            +
                      :p_description => "#{first_name} #{last_name}"
         | 
| 124 | 
            +
                    )
         | 
| 125 | 
            +
                  end
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                  # return value is ignored
         | 
| 128 | 
            +
                  set_delete_method do
         | 
| 129 | 
            +
                    plsql.test_employees_pkg.delete_employee(
         | 
| 130 | 
            +
                      :p_employee_id => id
         | 
| 131 | 
            +
                    )
         | 
| 132 | 
            +
                  end
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
              
         | 
| 137 | 
            +
              after(:all) do
         | 
| 138 | 
            +
                Object.send(:remove_const, "TestEmployee")
         | 
| 139 | 
            +
                @conn.execute "DROP TABLE test_employees"
         | 
| 140 | 
            +
                @conn.execute "DROP SEQUENCE test_employees_s"
         | 
| 141 | 
            +
                @conn.execute "DROP PACKAGE test_employees_pkg"
         | 
| 142 | 
            +
              end
         | 
| 143 | 
            +
             | 
| 144 | 
            +
              before(:each) do
         | 
| 145 | 
            +
                @today = Date.new(2008,6,28)
         | 
| 146 | 
            +
                @buffer = StringIO.new
         | 
| 147 | 
            +
              end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
              it "should create record" do
         | 
| 150 | 
            +
                @employee = TestEmployee.create(
         | 
| 151 | 
            +
                  :first_name => "First",
         | 
| 152 | 
            +
                  :last_name => "Last",
         | 
| 153 | 
            +
                  :hire_date => @today
         | 
| 154 | 
            +
                )
         | 
| 155 | 
            +
                @employee.reload
         | 
| 156 | 
            +
                @employee.first_name.should == "First"
         | 
| 157 | 
            +
                @employee.last_name.should == "Last"
         | 
| 158 | 
            +
                @employee.hire_date.should == @today
         | 
| 159 | 
            +
                @employee.description.should == "First Last"
         | 
| 160 | 
            +
                @employee.create_time.should_not be_nil
         | 
| 161 | 
            +
                @employee.update_time.should_not be_nil
         | 
| 162 | 
            +
              end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
              it "should update record" do
         | 
| 165 | 
            +
                @employee = TestEmployee.create(
         | 
| 166 | 
            +
                  :first_name => "First",
         | 
| 167 | 
            +
                  :last_name => "Last",
         | 
| 168 | 
            +
                  :hire_date => @today,
         | 
| 169 | 
            +
                  :description => "description"
         | 
| 170 | 
            +
                )
         | 
| 171 | 
            +
                @employee.reload
         | 
| 172 | 
            +
                @employee.first_name = "Second"
         | 
| 173 | 
            +
                @employee.save!
         | 
| 174 | 
            +
                @employee.reload
         | 
| 175 | 
            +
                @employee.description.should == "Second Last"
         | 
| 176 | 
            +
              end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
              it "should not update record if nothing is changed and partial updates are enabled" do
         | 
| 179 | 
            +
                return pending("Not in this ActiveRecord version") unless TestEmployee.respond_to?(:partial_updates=)
         | 
| 180 | 
            +
                TestEmployee.partial_updates = true
         | 
| 181 | 
            +
                @employee = TestEmployee.create(
         | 
| 182 | 
            +
                  :first_name => "First",
         | 
| 183 | 
            +
                  :last_name => "Last",
         | 
| 184 | 
            +
                  :hire_date => @today
         | 
| 185 | 
            +
                )
         | 
| 186 | 
            +
                @employee.reload
         | 
| 187 | 
            +
                @employee.save!
         | 
| 188 | 
            +
                @employee.reload
         | 
| 189 | 
            +
                @employee.version.should == 1
         | 
| 190 | 
            +
              end
         | 
| 191 | 
            +
             | 
| 192 | 
            +
              it "should update record if nothing is changed and partial updates are disabled" do
         | 
| 193 | 
            +
                return pending("Not in this ActiveRecord version") unless TestEmployee.respond_to?(:partial_updates=)
         | 
| 194 | 
            +
                TestEmployee.partial_updates = false
         | 
| 195 | 
            +
                @employee = TestEmployee.create(
         | 
| 196 | 
            +
                  :first_name => "First",
         | 
| 197 | 
            +
                  :last_name => "Last",
         | 
| 198 | 
            +
                  :hire_date => @today
         | 
| 199 | 
            +
                )
         | 
| 200 | 
            +
                @employee.reload
         | 
| 201 | 
            +
                @employee.save!
         | 
| 202 | 
            +
                @employee.reload
         | 
| 203 | 
            +
                @employee.version.should == 2
         | 
| 204 | 
            +
              end
         | 
| 205 | 
            +
             | 
| 206 | 
            +
              it "should delete record" do
         | 
| 207 | 
            +
                @employee = TestEmployee.create(
         | 
| 208 | 
            +
                  :first_name => "First",
         | 
| 209 | 
            +
                  :last_name => "Last",
         | 
| 210 | 
            +
                  :hire_date => @today
         | 
| 211 | 
            +
                )
         | 
| 212 | 
            +
                @employee.reload
         | 
| 213 | 
            +
                empl_id = @employee.id
         | 
| 214 | 
            +
                @employee.destroy
         | 
| 215 | 
            +
                @employee.should be_frozen
         | 
| 216 | 
            +
                TestEmployee.find_by_employee_id(empl_id).should be_nil
         | 
| 217 | 
            +
              end
         | 
| 218 | 
            +
             | 
| 219 | 
            +
              it "should log create record" do
         | 
| 220 | 
            +
                log_to @buffer
         | 
| 221 | 
            +
                @employee = TestEmployee.create(
         | 
| 222 | 
            +
                  :first_name => "First",
         | 
| 223 | 
            +
                  :last_name => "Last",
         | 
| 224 | 
            +
                  :hire_date => @today
         | 
| 225 | 
            +
                )
         | 
| 226 | 
            +
                @buffer.string.should match(/^TestEmployee Create \(\d+\.\d+(ms)?\)  custom create method$/)
         | 
| 227 | 
            +
              end
         | 
| 228 | 
            +
             | 
| 229 | 
            +
              it "should log update record" do
         | 
| 230 | 
            +
                (TestEmployee.partial_updates = false) rescue nil
         | 
| 231 | 
            +
                @employee = TestEmployee.create(
         | 
| 232 | 
            +
                  :first_name => "First",
         | 
| 233 | 
            +
                  :last_name => "Last",
         | 
| 234 | 
            +
                  :hire_date => @today
         | 
| 235 | 
            +
                )
         | 
| 236 | 
            +
                log_to @buffer
         | 
| 237 | 
            +
                @employee.save!
         | 
| 238 | 
            +
                @buffer.string.should match(/^TestEmployee Update \(\d+\.\d+(ms)?\)  custom update method with employee_id=#{@employee.id}$/)
         | 
| 239 | 
            +
              end
         | 
| 240 | 
            +
             | 
| 241 | 
            +
              it "should log delete record" do
         | 
| 242 | 
            +
                @employee = TestEmployee.create(
         | 
| 243 | 
            +
                  :first_name => "First",
         | 
| 244 | 
            +
                  :last_name => "Last",
         | 
| 245 | 
            +
                  :hire_date => @today
         | 
| 246 | 
            +
                )
         | 
| 247 | 
            +
                log_to @buffer
         | 
| 248 | 
            +
                @employee.destroy
         | 
| 249 | 
            +
                @buffer.string.should match(/^TestEmployee Destroy \(\d+\.\d+(ms)?\)  custom delete method with employee_id=#{@employee.id}$/)
         | 
| 250 | 
            +
              end
         | 
| 251 | 
            +
             | 
| 252 | 
            +
              it "should validate new record before creation" do
         | 
| 253 | 
            +
                @employee = TestEmployee.new(
         | 
| 254 | 
            +
                  :last_name => "Last",
         | 
| 255 | 
            +
                  :hire_date => @today
         | 
| 256 | 
            +
                )
         | 
| 257 | 
            +
                @employee.save.should be_false
         | 
| 258 | 
            +
                @employee.errors.on(:first_name).should_not be_nil
         | 
| 259 | 
            +
              end
         | 
| 260 | 
            +
             | 
| 261 | 
            +
              it "should validate existing record before update" do
         | 
| 262 | 
            +
                @employee = TestEmployee.create(
         | 
| 263 | 
            +
                  :first_name => "First",
         | 
| 264 | 
            +
                  :last_name => "Last",
         | 
| 265 | 
            +
                  :hire_date => @today
         | 
| 266 | 
            +
                )
         | 
| 267 | 
            +
                @employee.first_name = nil
         | 
| 268 | 
            +
                @employee.save.should be_false
         | 
| 269 | 
            +
                @employee.errors.on(:first_name).should_not be_nil
         | 
| 270 | 
            +
              end
         | 
| 271 | 
            +
              
         | 
| 272 | 
            +
            end
         | 
    
        data/spec/spec.opts
    ADDED
    
    
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            require 'rubygems'
         | 
| 2 | 
            +
            gem 'rspec'
         | 
| 3 | 
            +
            require 'spec'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            $:.unshift(File.dirname(__FILE__) + '/../lib')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            if ENV['RAILS_GEM_VERSION'] =~ /^2.0/
         | 
| 8 | 
            +
              gem 'activerecord', '=2.0.2'
         | 
| 9 | 
            +
              gem 'actionpack', '=2.0.2'
         | 
| 10 | 
            +
              gem 'activesupport', '=2.0.2'
         | 
| 11 | 
            +
              gem 'composite_primary_keys', '=0.9.93'
         | 
| 12 | 
            +
            elsif ENV['RAILS_GEM_VERSION'] =~ /^2.1/
         | 
| 13 | 
            +
              gem 'activerecord', '=2.1.2'
         | 
| 14 | 
            +
              gem 'actionpack', '=2.1.2'
         | 
| 15 | 
            +
              gem 'activesupport', '=2.1.2'
         | 
| 16 | 
            +
              gem 'composite_primary_keys', '=1.0.8'
         | 
| 17 | 
            +
            else
         | 
| 18 | 
            +
              gem 'activerecord', '=2.2.2'
         | 
| 19 | 
            +
              gem 'actionpack', '=2.2.2'
         | 
| 20 | 
            +
              gem 'activesupport', '=2.2.2'
         | 
| 21 | 
            +
              gem 'composite_primary_keys', '=2.2.0'
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            require 'activerecord'
         | 
| 25 | 
            +
            require 'actionpack'
         | 
| 26 | 
            +
            require 'action_controller/session/active_record_store'
         | 
| 27 | 
            +
            require 'active_record/connection_adapters/oracle_enhanced_adapter'
         | 
| 28 | 
            +
            gem "activerecord-oracle-adapter"
         | 
| 29 | 
            +
            require 'active_record/connection_adapters/oracle_adapter'
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            module LoggerSpecHelper
         | 
| 32 | 
            +
              def log_to(stream)
         | 
| 33 | 
            +
                ActiveRecord::Base.logger = Logger.new(stream)
         | 
| 34 | 
            +
                if ActiveRecord::Base.respond_to?(:connection_pool)
         | 
| 35 | 
            +
                  ActiveRecord::Base.connection_pool.clear_reloadable_connections!
         | 
| 36 | 
            +
                else
         | 
| 37 | 
            +
                  ActiveRecord::Base.clear_active_connections!
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
                ActiveRecord::Base.colorize_logging = false
         | 
| 40 | 
            +
                ActiveRecord::Base.logger.level = Logger::DEBUG
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,88 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: rwc9u-activerecord-oracle_enhanced-adapter
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              version: 1.1.9.3
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors: 
         | 
| 7 | 
            +
            - Raimonds Simanovskis (patched by Rob Christie
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            date: 2009-01-21 00:00:00 -08:00
         | 
| 13 | 
            +
            default_executable: 
         | 
| 14 | 
            +
            dependencies: 
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 16 | 
            +
              name: hoe
         | 
| 17 | 
            +
              version_requirement: 
         | 
| 18 | 
            +
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 19 | 
            +
                requirements: 
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 22 | 
            +
                    version: 1.8.0
         | 
| 23 | 
            +
                version: 
         | 
| 24 | 
            +
            description: Oracle enhanced adapter for Active Record. Additional patches to support ActiveRecord unit tests
         | 
| 25 | 
            +
            email: 
         | 
| 26 | 
            +
            - robchristie@gmail.com
         | 
| 27 | 
            +
            executables: []
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            extensions: []
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            extra_rdoc_files: 
         | 
| 32 | 
            +
            - History.txt
         | 
| 33 | 
            +
            - License.txt
         | 
| 34 | 
            +
            - Manifest.txt
         | 
| 35 | 
            +
            - README.txt
         | 
| 36 | 
            +
            files: 
         | 
| 37 | 
            +
            - "#oracle-enhanced.gemspec#"
         | 
| 38 | 
            +
            - History.txt
         | 
| 39 | 
            +
            - License.txt
         | 
| 40 | 
            +
            - Manifest.txt
         | 
| 41 | 
            +
            - README.txt
         | 
| 42 | 
            +
            - lib/active_record/connection_adapters/emulation/oracle_adapter.rb
         | 
| 43 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced.rake
         | 
| 44 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_adapter.rb
         | 
| 45 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_cpk.rb
         | 
| 46 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_dirty.rb
         | 
| 47 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_procedures.rb
         | 
| 48 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_reserved_words.rb
         | 
| 49 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_tasks.rb
         | 
| 50 | 
            +
            - lib/active_record/connection_adapters/oracle_enhanced_version.rb
         | 
| 51 | 
            +
            - oracle-enhanced.gemspec
         | 
| 52 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb
         | 
| 53 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb
         | 
| 54 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb
         | 
| 55 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb
         | 
| 56 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb
         | 
| 57 | 
            +
            - spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb
         | 
| 58 | 
            +
            - spec/spec.opts
         | 
| 59 | 
            +
            - spec/spec_helper.rb
         | 
| 60 | 
            +
            has_rdoc: true
         | 
| 61 | 
            +
            homepage: http://oracle-enhanced.rubyforge.org
         | 
| 62 | 
            +
            post_install_message: ""
         | 
| 63 | 
            +
            rdoc_options: 
         | 
| 64 | 
            +
            - --main
         | 
| 65 | 
            +
            - README.txt
         | 
| 66 | 
            +
            require_paths: 
         | 
| 67 | 
            +
            - lib
         | 
| 68 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 69 | 
            +
              requirements: 
         | 
| 70 | 
            +
              - - ">="
         | 
| 71 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 72 | 
            +
                  version: "0"
         | 
| 73 | 
            +
              version: 
         | 
| 74 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 75 | 
            +
              requirements: 
         | 
| 76 | 
            +
              - - ">="
         | 
| 77 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 78 | 
            +
                  version: "0"
         | 
| 79 | 
            +
              version: 
         | 
| 80 | 
            +
            requirements: []
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            rubyforge_project: oracle-enhanced
         | 
| 83 | 
            +
            rubygems_version: 1.2.0
         | 
| 84 | 
            +
            signing_key: 
         | 
| 85 | 
            +
            specification_version: 2
         | 
| 86 | 
            +
            summary: Oracle enhaced adapter for Active Record
         | 
| 87 | 
            +
            test_files: []
         | 
| 88 | 
            +
             |