Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redmine now includes a optional tracker_id field #643

Closed
wants to merge 1 commit into from

Conversation

brodock
Copy link
Contributor

@brodock brodock commented Jan 30, 2014

By defining a tracker_id, you can make sure that
the ticket will be created with the right "type".

If it is not filled, then it fallbacks to default
which is the first in the priority list that is
available to the project.

this fixes #585

By defining a tracker_id, you can make sure that
the ticket will be created with the right "type".

If it is not filled, then it fallbacks to default
which is the first in the priority list that is
available to the project.
@arthurnn
Copy link
Member

looks like ci is 🔴

@brodock
Copy link
Contributor Author

brodock commented Jan 31, 2014

I haven't executed all the specs, just the one I modified (my fault).

Here is the failed spec:

        IssueTracker.subclasses.each do |tracker_klass|
          context tracker_klass do
            it "should save tracker params" do
              params = tracker_klass::Fields.inject({}){|hash,f| hash[f[0]] = "test_value"; hash }
              params[:ticket_properties] = "card_type = defect" if tracker_klass == MingleTracker
              params[:type] = tracker_klass.to_s
              put :update, :id => @app.id, :app => {:issue_tracker_attributes => params}

              @app.reload

              tracker = @app.issue_tracker
              expect(tracker).to be_a(tracker_klass)
              tracker_klass::Fields.each do |field, field_info|
                case field
                when :ticket_properties
                  expect(tracker.send(field.to_sym)).to eq 'card_type = defect'
                else
                  expect(tracker.send(field.to_sym)).to eq 'test_value'
                end
              end
            end

What is wrong is that it has a very simple "mock" for every field. This can be fixed in 2 ways:

  1. I can remove the type check I've included to make sure "tracker_id" is in fact a number
  2. The test need to be changed to use either fixtures (and give sane values) or something like Fabrication or FactoryGirl

The code that makes this test fails is here:

    def check_params
      if Fields.detect {|f| self[f[0]].blank? && !f[1][:optional]}
        errors.add :base, 'You must specify your Redmine URL, API token, Username, Password and Project ID'
      end

      # this is the code that fails the other test, because it trys to set "tracker_id=test_value"
      if Fields.detect {|f| f[0] == :tracker_id && !self[f[0]].blank? && !/[0-9]/.match(self[f[0]].to_s)}
        errors.add :base, 'Issue Tracker Id must be a number'
      end
    end

@brodock
Copy link
Contributor Author

brodock commented Feb 3, 2014

Should I also extract it to a gem, as suggested by: #612 ?
Please let me know the directions and I will update this PR.

@shingara
Copy link
Member

it can be good if you extract to a gem because I need to do it soon.

@brodock
Copy link
Contributor Author

brodock commented Feb 19, 2014

any suggestion according to the (lack of) factory issue?

@brodock
Copy link
Contributor Author

brodock commented May 29, 2014

Can you please provide instructions or an example gem?
I've created some already, but don't really know how to extract just this piece into a gem and link it to Errbit.

As a side question, can I refactory some tests and implement a factory for all the trackers or you have another idea in mind?

While errbit works the way it is right now, I'm missing some instrumentations to do a better job.

@stevecrozz-
Copy link

@brodock I've got examples now for you. Please take a look at the latest activity on #612 where I've referenced some examples.

@brodock
Copy link
Contributor Author

brodock commented Dec 7, 2014

I've sent a pull request to the "errbit_redmine_plugin".

I beleive that all oficial plugins should be at "errbit" organization. Are there any plans to move it there?

I'm closing it right now as It has nothing more to do here.

@brodock brodock closed this Dec 7, 2014
@stevecrozz-
Copy link

I agree about where the plugins should live. I just don't have permission to create repos in this organization. I think I'll be asking for that permission soon. I'll check out your PR now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redmine issue integration should ask for tracker_id
4 participants