Avoid defining same constants in multiple specs

pull/3606/head
Mohamed Wael Khobalatte 9 years ago
parent 8015984218
commit 03cce5e25d
  1. 4
      spec/lib/custom_field_form_builder_spec.rb
  2. 4
      spec/lib/journal_formatter/attachment_spec.rb
  3. 4
      spec/lib/journal_formatter/custom_field_spec.rb
  4. 4
      spec/lib/journal_formatter/diff_spec.rb
  5. 4
      spec/lib/tabular_form_builder_spec.rb
  6. 6
      spec/requests/api/v3/authentication_spec.rb

@ -29,12 +29,10 @@
require 'spec_helper' require 'spec_helper'
require 'ostruct' require 'ostruct'
TestViewHelper = Class.new(ActionView::Base)
describe CustomFieldFormBuilder do describe CustomFieldFormBuilder do
include Capybara::RSpecMatchers include Capybara::RSpecMatchers
let(:helper) { TestViewHelper.new } let(:helper) { ActionView::Base.new }
let(:resource) { let(:resource) {
FactoryGirl.build(:user, FactoryGirl.build(:user,
firstname: 'JJ', firstname: 'JJ',

@ -40,13 +40,11 @@ describe OpenProject::JournalFormatter::Attachment do
{ only_path: true } { only_path: true }
end end
Struct.new('TestJournal', :id)
let(:klass) { OpenProject::JournalFormatter::Attachment } let(:klass) { OpenProject::JournalFormatter::Attachment }
let(:instance) { klass.new(journal) } let(:instance) { klass.new(journal) }
let(:id) { 1 } let(:id) { 1 }
let(:journal) do let(:journal) do
Struct::TestJournal.new(id) OpenStruct.new(id: id)
end end
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryGirl.create(:user) }
let(:attachment) { let(:attachment) {

@ -32,13 +32,11 @@ describe OpenProject::JournalFormatter::CustomField do
include CustomFieldsHelper include CustomFieldsHelper
include ActionView::Helpers::TagHelper include ActionView::Helpers::TagHelper
Struct.new('TestJournal', :id)
let(:klass) { OpenProject::JournalFormatter::CustomField } let(:klass) { OpenProject::JournalFormatter::CustomField }
let(:instance) { klass.new(journal) } let(:instance) { klass.new(journal) }
let(:id) { 1 } let(:id) { 1 }
let(:journal) do let(:journal) do
Struct::TestJournal.new(id) OpenStruct.new(id: id)
end end
let(:user) { FactoryGirl.create(:user) } let(:user) { FactoryGirl.create(:user) }
let(:custom_field) { FactoryGirl.create(:issue_custom_field) } let(:custom_field) { FactoryGirl.create(:issue_custom_field) }

@ -38,12 +38,10 @@ describe OpenProject::JournalFormatter::Diff do
Rails.application.routes.url_helpers Rails.application.routes.url_helpers
end end
Struct.new('TestJournal', :id, :journable)
let(:klass) { OpenProject::JournalFormatter::Diff } let(:klass) { OpenProject::JournalFormatter::Diff }
let(:id) { 1 } let(:id) { 1 }
let(:journal) do let(:journal) do
Struct::TestJournal.new(id, WorkPackage.new) OpenStruct.new(id: id, journable: WorkPackage.new)
end end
let(:instance) { klass.new(journal) } let(:instance) { klass.new(journal) }
let(:key) { 'description' } let(:key) { 'description' }

@ -29,12 +29,10 @@
require 'spec_helper' require 'spec_helper'
require 'ostruct' require 'ostruct'
TestViewHelper = Class.new(ActionView::Base)
describe TabularFormBuilder do describe TabularFormBuilder do
include Capybara::RSpecMatchers include Capybara::RSpecMatchers
let(:helper) { TestViewHelper.new } let(:helper) { ActionView::Base.new }
let(:resource) { let(:resource) {
FactoryGirl.build(:user, FactoryGirl.build(:user,
firstname: 'JJ', firstname: 'JJ',

@ -44,7 +44,7 @@ describe API::V3, type: :request do
let(:expected_message) { 'You need to be authenticated to access this resource.' } let(:expected_message) { 'You need to be authenticated to access this resource.' }
Strategies = OpenProject::Authentication::Strategies::Warden strategies = OpenProject::Authentication::Strategies::Warden
def basic_auth(user, password) def basic_auth(user, password)
credentials = ActionController::HttpAuthentication::Basic.encode_credentials user, password credentials = ActionController::HttpAuthentication::Basic.encode_credentials user, password
@ -148,7 +148,7 @@ describe API::V3, type: :request do
let(:password) { 'toor' } let(:password) { 'toor' }
before do before do
Strategies::GlobalBasicAuth.configure! user: 'root', password: 'toor' strategies::GlobalBasicAuth.configure! user: 'root', password: 'toor'
end end
it_behaves_like 'it is basic auth protected' it_behaves_like 'it is basic auth protected'
@ -190,7 +190,7 @@ describe API::V3, type: :request do
before do before do
config = { user: 'global_account', password: 'global_password' } config = { user: 'global_account', password: 'global_password' }
Strategies::GlobalBasicAuth.configure! config strategies::GlobalBasicAuth.configure! config
end end
context 'without credentials' do context 'without credentials' do

Loading…
Cancel
Save